使用poi时报错:java.io.EOFException: Unexpected end of ZLIB input stream

原文:

点击查看代码
File excelFile = new File(filePath);
try {
   if (excelFile.exists()) {
      wb = new SXSSFWorkbook(new XSSFWorkbook(excelFile), 1000,true);
   } else {
      wb = new SXSSFWorkbook(1000);
   }
} catch (IOException e) {
   logger.error(trackId + e.getMessage(), e);
}

excelFile改为new FileInputStream(filePath) 即解决报错

点击查看代码
File excelFile = new File(filePath);
try {
   if (excelFile.exists()) {
      wb = new SXSSFWorkbook(new XSSFWorkbook(new FileInputStream(filePath)), 1000,true);
   } else {
      wb = new SXSSFWorkbook(1000);
   }
} catch (IOException e) {
   logger.error(trackId + e.getMessage(), e);
}
posted @ 2023-06-20 19:35  小小黑₯(≧∇≦)ノ  阅读(763)  评论(0)    收藏  举报