繁体   English   中英

如何为 XLSReader 配置 XML-config

[英]How to configure XML-config for XLSReader

我正在使用org.jxls:jxls-reader从 excel 表中读取一些数据。 这些行从 excel 第 20 行开始,应该读取到下一行为空。 但是我无法正确配置 xml-config 以读取行。

第一行之后的每一行都返回一个null值。

我试图了解http://jxls.sourceforge.net/reference/reader.html中提供的departmentdata.xls但我无法正确理解。

对配置的一些见解将不胜感激。

我在ExcelUploadController中的代码:

            InputStream xmlInputStream = new FileInputStream(xmlFile)

            XLSReader reader = ReaderBuilder.buildFromXML(xmlInputStream);

            InputStream xlsInputStream = dataFile.getInputStream();

            DocumentDetailPosition documentDetailPosition = new DocumentDetailPosition();

            List<DocumentDetailPosition> documentDetailPositions = new ArrayList<>();

            Map<String, Object> beans = new HashMap<>();

            beans.put("documentDetailPosition", documentDetailPosition);

            beans.put("documentDetailPositions", documentDetailPositions);

            XLSReadStatus status = reader.read(xlsInputStream, beans)

我的xml-Config

   <workbook>
       <worksheet name="worksheet1">
        <section startRow="0" endRow="19"/>
            <loop startRow="19" endRow="29" items="documentDetailPositions" var="documentDetailPosition" varType="pl.fissst.crm.esales.pojo.DocumentDetailPosition">
               <section startRow="19" endRow="29">
                   <mapping row="19" col="0" type="java.lang.Integer">documentDetailPosition.posProductNo</mapping>
                   <mapping row="19" col="1" type="java.lang.Integer">documentDetailPosition.quantity</mapping>
                   <mapping row="19" col="3"  type="java.util.Date">documentDetailPosition.requestDate</mapping>
               </section>
               <loopbreakcondition>
                   <rowcheck offset="0"/>
                   <cellcheck offset="0"></cellcheck>
               </loopbreakcondition>
           </loop>
       </worksheet>
    </workbook>

当 DocumentDetail 的值被打印时,日志显示:

INFO  885744 g.a.c.p.f.c.e.ExcelUploadController - 1234567
INFO  885744 g.a.c.p.f.c.e.ExcelUploadController - 5 
INFO  885746 g.a.c.p.f.c.e.ExcelUploadController - Thu Jan 03 00:00:00 CET 2019 

INFO  885746 g.a.c.p.f.c.e.ExcelUploadController - null 
INFO  885746 g.a.c.p.f.c.e.ExcelUploadController - null 
INFO  885746 g.a.c.p.f.c.e.ExcelUploadController - null 

预期行为:读取所有行

实际结果:读取第一行,然后一切都是null

在您的循环标记中,startRow 和 endRow 必须相同。 在您的 loopbreakcondition 中, cellcheck 标记位于 rowcheck 标记内。

而且我不确定映射是否适用于与字符串不同的东西

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM