【现象】
Exception in thread "main" org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)
at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:131)
at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:104)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:138)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:322)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:303)
【解决方法】
FileInputStream inps = new FileInputStream(System.getProperty("user.dir")+"\\运费.xlsx"); //读取工作簿 HSSFWorkbook workBook = new HSSFWorkbook(inps); //读取工作表 HSSFSheet sheet = workBook.getSheetAt(0);
修改为:
FileInputStream inps = new FileInputStream(System.getProperty("user.dir")+"\\运费.xlsx"); //读取工作簿 XSSFWorkbook workBook = new XSSFWorkbook(inps); //读取工作表 XSSFSheet sheet = workBook.getSheetAt(0);
更多推荐
You need to call a different part of POI to process this data (eg XSSF instead o
发布评论