2017-04-03 39 views
0

我正在使用文件连接器从an Excel file (xlsx)读取数据,并使用数据编织将数据转换为application/java。如果在类型为Accounting的Excel中有任何单元格,我会得到此例外:无法从文本单元格中获取数值Mule Dataweave

消息:无法从文本单元格获取数值(java.lang.IllegalStateException)。 有效载荷:[email protected]

<dw:input-payload mimeType="application/xlsx"> 
</dw:input-payload> 

这里是dataweave:

%dw 1.0 
%output application/java 
--- 

payload."Sheet1" map ((sheet1 , indexOfSheet1) -> { 
    id: sheet1.id 
}) 

如果单元格的格式更改为一般,异常消失了。我怎样才能得到这个会计类型的单元格的excel工作?

+0

日志消息请提供你的excel文件和dataweave,引起异常 – Yevgeniy

+0

%干重1.0% 输出应用/ JAVA --- 有效载荷 “Sheet 1中” 地图((Sheet 1中indexOfSheet1) - > { \t编号:sheet1.id })https://drive.google.com/open?id=0B2VwKPUfZyE0NUJvYzZZNmNIdkk – user94538

回答

0

我在本地Anypoint Studio中创建了与Studio 6.2.3版本和Mule runtime 3.8.1 EE相同的场景,EE遇到了几个问题。我更新运行时到3.8.3 EE所有问题都没有了&一切似乎都工作正常。验证你是否有任何版本问题,Excel支持最近添加到dataweave,仍然在测试版。

https://forums.mulesoft.com/questions/42650/ms-excelxls-on-dataweave.html

这里是为我工作

   <?xml version="1.0" encoding="UTF-8"?> 
    <mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" 
     xmlns:spring="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
    http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd 
    http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd"> 
     <flow name="xslxreaderFlow"> 
      <file:inbound-endpoint path="C:\files\input" responseTimeout="10000" doc:name="File"/> 
      <dw:transform-message doc:name="Transform Message" metadata:id="aa47f058-609d-4d96-9646-a52accacaf9f"> 
       <dw:input-payload doc:sample="sample_data\excel_1.xlsx" mimeType="application/xlsx"/> 
       <dw:set-payload><![CDATA[%dw 1.0 
    %output application/java 
    --- 

    payload."Sheet1" map ((sheet1 , indexOfSheet1) -> { 
     id: sheet1.ID, 
     amount:sheet1.Amount 
    })]]></dw:set-payload> 
      </dw:transform-message> 
      <logger message="#[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/> 
     </flow> 
    </mule> 

输出结果从控制台

INFO 2017-04-04 16:46:57,940 [[test].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\files\input\Book1.xlsx 
INFO 2017-04-04 16:47:00,719 [[test].xslxreaderFlow.stage1.02] org.mule.api.processor.LoggerMessageProcessor: [{id=123456, amount=5000.75}, {id=234567, amount=45367.34}] 

这里的流量为您的文件

INFO 2017-04-06 09:37:38,650 [[test].connector.file.mule.default.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: C:\files\input\file1.xlsx 
INFO 2017-04-06 09:37:38,792 [[test].xslxreaderFlow.stage1.03] org.mule.api.processor.LoggerMessageProcessor: [{id=1234, amount=500.5}, {id=456, amount=700.25}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}, {id=, amount=}] 
+0

您是否使用过我作为输入源附加的excel?我在3.8.3 EE运行时版本上。我的流程可以成功读取excel文件,但不能读取我附加的文件。这是因为金额字段的数据类型。如果你点击格式单元格,你会看到它是会计。如果我将其更改为常规,一切正常。如果在excel输入源中有会计格式的任何字段,我怎么才能得到这个工作? – user94538

+0

我通过从谷歌驱动下载你的文件运行,似乎工作正常,但它也产生空白单元格。我添加了日志消息到我的答案。 – ssanrao

+0

当然流程正在读取文件,并在拾取后被删除,因为我没有将autoDelete设置为false。文件名模式是可选参数,我添加到流程仍然照常运行。让我知道任何问题。 – ssanrao