2017-04-03 40 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