org.apache.poi.openxml4j.exceptions.InvalidOperationException:尝试使用poi读取.csv文件时无法打开指定的文件

时间:2014-06-27 22:21:54

标签: java excel-2007 apache-poi

信息:服务器启动时间为1778毫秒 org.apache.poi.openxml4j.exceptions.InvalidOperationException:无法打开指定的文件:'C:\ Users \ raj \ AppData \ Local \ Temp \ poifiles \ poi-ooxml - 2049907849.tmp'     在org.apache.poi.openxml4j.opc.ZipPackage。(ZipPackage.java:102)     在org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:199)     在org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:178)     在org.apache.poi.util.PackageHelper.open(PackageHelper.java:53)     在org.apache.poi.xssf.usermodel.XSSFWorkbook。(XSSFWorkbook.java:155)     在com.web.controller.ExcelReader.processUploadedFile(ExcelReader.java:83)     在com.web.controller.ExcelReader.doPost(ExcelReader.java:68)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:641)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:722)     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)     在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)     在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)     在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)     在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)     在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)     在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)     在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)     在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)     at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:565)     在org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:309)     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:603)     在java.lang.Thread.run(Thread.java:722)

1 个答案:

答案 0 :(得分:2)

Apache POI只能读取Excel .xls(通过HSSF)和Excel .xslx(通过XSSF)。它无法打开CSV文件

要使用CSV文件,您需要使用其他库。或者,如果将文件另存为.xls或.xlsx,则可以使用Apache POI处理它。