我目前正在尝试从Java中读取.xls文件,该文件的第一行中包含字符“°”,但我在HSSFWorkbook构造函数中遇到了错误。
FileInputStream fileInputStream = new FileInputStream(new File(path));
HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);
我得到了:
org.apache.poi.hssf.record.LabelRecord cannot be cast to java.lang.Comparable
如果我删除字符'°'
,一切正常。
完整的堆栈跟踪:
java.lang.ClassCastException: org.apache.poi.hssf.record.LabelRecord cannot be cast to java.lang.Comparable
at java.util.TreeMap.put(Unknown Source)
at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.insertCell(ValueRecordsAggregate.java:65)
at org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.construct(ValueRecordsAggregate.java:130)
at org.apache.poi.hssf.model.Sheet.createSheet(Sheet.java:210)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:172)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:210)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:191)
at adp.servlet.UploadPPIPServlet.readExcel(UploadPPIPServlet.java:342)
at adp.servlet.UploadPPIPServlet.process(UploadPPIPServlet.java:87)
at frmw.BaseServlet.doPost(BaseServlet.java:283)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:612)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:503)
at java.lang.Thread.run(Unknown Source)