Java读取Excel报错Unable to recognize OLE stream
- 2020 年 11 月 12 日
- 筆記
Unable to recognize OLE stream 的解决方法
将xlsx用excel打开并另存为2003的xls,然后再运行即可解决问题
File file = new File("E:\\work.xls"); Workbook workbook = Workbook.getWorkbook(file); //2:获取第一个工作表sheet Sheet sheet = workbook.getSheet(0); for (int i = 0; i < sheet.getRows(); i++) { Stu bean = null; String name=""; String num=""; for (int j = 0; j < sheet.getColumns(); j++) { Cell cell = sheet.getCell(j, i); bean = new Stu(); if (j == 1) name = cell.getContents(); if (j == 4) num = cell.getContents(); } map.put(name,num); } //最后一步:关闭资源 workbook.close();