Excel導出打印失敗報錯 (eg HSSF instead of XSSF)

錯誤信息:java

java.lang.RuntimeException: org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException: The supplied data appears to be in the OLE2 Format. You are calling the part of POI that deals with OOXML (Office Open XML) Documents. You need to call a different part of POI to process this data (eg HSSF instead of XSSF) apache

 

緣由是由於:session

InputStream inputStream = session.getServletContext().getResourceAsStream("make/xlsprint/tOUTPRODUCT.xlsx");
Workbook workbook = new XSSFWorkbook(inputStream),XSSF操做的是Excel2007以上的版本,對應文件的後綴名是xlsx
Workbook workbook = new HSSFWorkbook(inputStream),HSSF操做的是Excel2003之前的版本,對應的文件後綴名是xls檢查輸入流導入的文件的Excel的版本,使用對應的POI操做
相關文章
相關標籤/搜索