[alibaba/easyexcel]读取数据发现一个BUG

2024-04-30 443 views
8
触发Bug的代码
这是JAVA代码
  EasyExcel.read(selectedFile.getFilePath(), commonExcelDataListener).
                                        headRowNumber(0).ignoreEmptyRow(false).sheet().doRead();
读监听
public class CommonExcelDataListener extends AnalysisEventListener<Map<Integer,String>> {

    private List<Map<Integer,String>> cachedDataList = new ArrayList<>();

    public List<Map<Integer, String>> getCachedDataList() {
        return cachedDataList;
    }

    @Override
    public void invoke(Map<Integer, String> data, AnalysisContext context) {
        cachedDataList.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
    }

    @Override
    public void extra(CellExtra extra, AnalysisContext context) {
    }
}

异常信息 java.lang.RuntimeException: Coding Error: Expected ExpPtg to be converted from Shared to Non-Shared Formula by ValueRecordsAggregate, but it wasn't at org.apache.poi.ss.formula.ptg.ExpPtg.toFormulaString(ExpPtg.java:62) at org.apache.poi.ss.formula.FormulaRenderer.toFormulaString(FormulaRenderer.java:95) at org.apache.poi.hssf.model.HSSFFormulaParser.toFormulaString(HSSFFormulaParser.java:90) at com.alibaba.excel.analysis.v03.handlers.FormulaRecordHandler.processRecord(FormulaRecordHandler.java:42) at com.alibaba.excel.analysis.v03.XlsSaxAnalyser.processRecord(XlsSaxAnalyser.java:157) at org.apache.poi.hssf.eventusermodel.MissingRecordAwareHSSFListener.processRecord(MissingRecordAwareHSSFListener.java:201) at org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener.processRecord(FormatTrackingHSSFListener.java:92) at org.apache.poi.hssf.eventusermodel.HSSFRequest.processRecord(HSSFRequest.java:106) at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.genericProcessEvents(HSSFEventFactory.java:172) at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processEvents(HSSFEventFactory.java:129) at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processWorkbookEvents(HSSFEventFactory.java:80) at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processWorkbookEvents(HSSFEventFactory.java:53) at com.alibaba.excel.analysis.v03.XlsSaxAnalyser.execute(XlsSaxAnalyser.java:136) at com.alibaba.excel.analysis.ExcelAnalyserImpl.analysis(ExcelAnalyserImpl.java:124) at com.alibaba.excel.ExcelReader.read(ExcelReader.java:66) at com.alibaba.excel.ExcelReader.read(ExcelReader.java:56) at com.alibaba.excel.read.builder.ExcelReaderSheetBuilder.doRead(ExcelReaderSheetBuilder.java:65) at com.scdatax.modules.importdata.service.impl.XbrlIndicatorDataServiceImpl$2$1.call(XbrlIndicatorDataServiceImpl.java:155) at com.scdatax.modules.importdata.service.impl.XbrlIndicatorDataServiceImpl$2$1.call(XbrlIndicatorDataServiceImpl.java:145) at javafx.concurrent.Task$TaskCallable.call(Task.java:1423) at java.util.concurrent.FutureTask.run(Unknown Source) at javafx.concurrent.Service.lambda$null$6(Service.java:725) at java.security.AccessController.doPrivileged(Native Method) at javafx.concurrent.Service.lambda$executeTask$7(Service.java:724) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

回答

7

文件呢

6

你这excel里面全是公式 你要定义实体或者手动注册转换器