https://bz.apache.org/bugzilla/show_bug.cgi?id=69021
Bug ID: 69021 Summary: HSSF: Java.lang.ClassCastException: class org.apache.poi.hssf.record.DSFRecord cannot be cast to class org.apache.poi.hssf.record.TabIdRecord Product: POI Version: unspecified Hardware: PC Status: NEW Severity: normal Priority: P2 Component: HSSF Assignee: dev@poi.apache.org Reporter: mengxiansong2...@163.com Target Milestone: --- I have an very old .xls file,when I use code blow to change its content: ``` String filePath = "D:\\BRD2002.xls"; try { Workbook workbook = new HSSFWorkbook(new FileInputStream(filePath)); Sheet sheet = workbook.getSheetAt(0); int rowIndex = 2; sheet.shiftRows(rowIndex, sheet.getLastRowNum(), 1); Row row = sheet.createRow(rowIndex); row.createCell(0).setCellValue("switch"); FileOutputStream outputStream = new FileOutputStream(filePath); workbook.write(outputStream); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } ``` An Exception came out At row:'workbook.write(outputStream);' Exception details: ``` java.lang.ClassCastException: class org.apache.poi.hssf.record.DSFRecord cannot be cast to class org.apache.poi.hssf.record.TabIdRecord (org.apache.poi.hssf.record.DSFRecord and org.apache.poi.hssf.record.TabIdRecord are in unnamed module of loader 'app') at org.apache.poi.hssf.model.InternalWorkbook.preSerialize(InternalWorkbook.java:1078) at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:1506) at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1424) at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1410) at com.fzm.batch.InsertRowInXLS.main(InsertRowInXLS.java:25) ``` When I commented out the line of code that contains "sheet.shiftRows" and executed it again, there were no exceptions anymore. -- 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