我正在使用文件连接器从an Excel file (xlsx)读取数据,并使用数据编织将数据转换为application / java。如果excel中有任何类型为Accounting的单元格,我将收到此异常:
消息:无法从文本单元格中获取数值(java.lang.IllegalStateException)。 有效载荷:com.mulesoft.weave.reader.DefaultSeekableStream@6fe3727f
<dw:input-payload mimeType="application/xlsx">
</dw:input-payload>
这是数据编织:
%dw 1.0
%output application/java
---
payload."Sheet1" map ((sheet1 , indexOfSheet1) -> {
id: sheet1.id
})
如果单元格格式更改为“常规”,则异常消失。如何使用会计类型的单元格为Excel工作?
答案 0 :(得分:0)
我最初使用Studio版本6.2.3在我的本地anypoint studio中创建了相同的场景,而Mule运行时3.8.1 EE遇到了几个问题。我将运行时更新到3.8.3 EE所有问题都消失了&amp;一切似乎都很好。验证您是否有任何版本问题,最近添加到dataweave并仍处于测试阶段的Excel支持。
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=}]