Summary: | Calling shiftRows on a xlsx file corrupts the workbook | ||
---|---|---|---|
Product: | POI | Reporter: | Vinu Kumar <vinu.kumar> |
Component: | XSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 3.5-dev | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows Server 2003 | ||
Attachments: |
Repro file for the issue
xlsx file used for testing |
Created attachment 23227 [details]
xlsx file used for testing
fixed by modifying the following code is in XSSFCell.java protected void modifyCellReference(XSSFRow row) { this.cell.setR(new CellReference(row.getRowNum(), cellNum).formatAsString()); CTCell[] ctCells = row.getCTRow().getCArray(); for (CTCell ctCell : ctCells) { ctCell.setR(new CellReference(row.getRowNum(), cellNum).formatAsString()); } } with this: protected void modifyCellReference(XSSFRow row) { int cnum = 0; this.cell.setR(new CellReference(row.getRowNum(), cnum).formatAsString()); CTCell[] ctCells = row.getCTRow().getCArray(); for (CTCell ctCell : ctCells) { ctCell.setR(new CellReference(row.getRowNum(), cnum++).formatAsString()); } } This is fixed in the latest trunk |
Created attachment 23226 [details] Repro file for the issue Read an xlsx file and call shiftRows. Write the resultant workbook to a file and open in MS office 2007. Office throws the following error "Excel found unreadable content." and asks for recovering. Following recovery message is thrown: Removed Records: Cell information from /xl/worksheets/sheet1.xml part The row gets shifted but it shifts the first column and last column is lost.