https://bz.apache.org/bugzilla/show_bug.cgi?id=68854
Bug ID: 68854 Summary: org.apache.poi.hssf.record.RecordInputStream$LeftoverD ataException: Initialisation of record 0x31(FontRecord) left 4 bytes remaining still to be read. Product: POI Version: unspecified Hardware: PC Status: NEW Severity: normal Priority: P2 Component: XSSF Assignee: dev@poi.apache.org Reporter: 2099...@qq.com Target Milestone: --- Created attachment 39645 --> https://bz.apache.org/bugzilla/attachment.cgi?id=39645&action=edit org.apache.poi.hssf.record.RecordInputStream$LeftoverDataException: Initialisation of record 0x31(FontRecord) left 4 bytes remaining still to be read. The code is shown below,The code is shown below: import org.apache.poi.ss.usermodel.*; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class ExcelReaderExample { public static void main(String[] args) { String filePath = "D:\\坪山区石楼路(汤达路-汤坑二路)市政工程-道路工程(单位工程).xls";; // 更换为你的文件路径 try { // 使用WorkbookFactory创建合适的Workbook实例,自动识别文件格式 Workbook workbook = WorkbookFactory.create(new FileInputStream(new File(filePath))); // 获取第一个工作表 Sheet sheet = workbook.getSheetAt(0); // 遍历所有行 for (Row row : sheet) { // 遍历所有单元格 for (Cell cell : row) { // 根据单元格类型读取数据 switch (cell.getCellType()) { case STRING: System.out.print(cell.getRichStringCellValue().getString() + "\t"); break; case NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { System.out.print(cell.getDateCellValue() + "\t"); } else { System.out.print(cell.getNumericCellValue() + "\t"); } break; case BOOLEAN: System.out.print(cell.getBooleanCellValue() + "\t"); break; case FORMULA: System.out.print(cell.getCellFormula() + "\t"); break; default: System.out.print(" " + "\t"); } } System.out.println(); } workbook.close(); } catch (IOException ex) { ex.printStackTrace(); } } } The following error message appears when running the code. Exception in thread "main" org.apache.poi.hssf.record.RecordInputStream$LeftoverDataException: Initialisation of record 0x31(FontRecord) left 4 bytes remaining still to be read. at org.apache.poi.hssf.record.RecordInputStream.hasNextRecord(RecordInputStream.java:188) at org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:235) at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:488) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:343) at org.apache.poi.hssf.usermodel.HSSFWorkbookFactory.createWorkbook(HSSFWorkbookFactory.java:64) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:167) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:112) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:253) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:221) at com.costbox.common.dataanalyze.test.ExcelReaderExample.main(ExcelReaderExample.java:14) Process finished with exit code 1 -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org