2
easyexcel版本是2.1.6。在读取一个excel文件时出现ExcelDataConvertException
异常,源代码如下:
SummaryReadListener summaryReadListener = new SummaryReadListener();
EasyExcel.read("C:\\1.xlsx", summaryReadListener).head(ResultSummary.class).sheet(0).doRead();
异常的详细信息如下:
com.alibaba.excel.exception.ExcelAnalysisException: com.alibaba.excel.exception.ExcelDataConvertException: Converter not found, convert STRING to String
at com.alibaba.excel.analysis.v07.XlsxSaxAnalyser.parseXmlSource(XlsxSaxAnalyser.java:170)
at com.alibaba.excel.analysis.v07.XlsxSaxAnalyser.execute(XlsxSaxAnalyser.java:189)
at com.alibaba.excel.analysis.ExcelAnalyserImpl.analysis(ExcelAnalyserImpl.java:105)
at com.alibaba.excel.ExcelReader.read(ExcelReader.java:180)
at com.alibaba.excel.ExcelReader.read(ExcelReader.java:170)
at com.alibaba.excel.read.builder.ExcelReaderSheetBuilder.doRead(ExcelReaderSheetBuilder.java:160)
at test.Demo.main(Demo.java:17)
Caused by: com.alibaba.excel.exception.ExcelDataConvertException: Converter not found, convert STRING to String
at com.alibaba.excel.util.ConverterUtils.convertToStringMap(ConverterUtils.java:55)
at com.alibaba.excel.read.metadata.holder.AbstractReadHolder.buildHead(AbstractReadHolder.java:197)
at com.alibaba.excel.read.metadata.holder.AbstractReadHolder.notifyEndOneRow(AbstractReadHolder.java:163)
at com.alibaba.excel.analysis.v07.handlers.ProcessResultCellHandler.endHandle(ProcessResultCellHandler.java:45)
at com.alibaba.excel.analysis.v07.XlsxRowHandler.endElement(XlsxRowHandler.java:44)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2967)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:842)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:771)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at com.alibaba.excel.analysis.v07.XlsxSaxAnalyser.parseXmlSource(XlsxSaxAnalyser.java:165)
... 28 more
该异常是在生产环境出现的。在开发环境跟踪了代码,在初始化com.alibaba.excel.read.metadata.holder.AbstractReadHolder
类时就把所有自带的Converter
加载了,包括com.alibaba.excel.converters.string.StringStringConverter
类,并没有出现该异常。
所以是什么原因会引起这个异常呢?