Summary: | XSSFSheet.addIgnoredErrors(CellReference, IgnoredErrorType) creates corrupt Excel file | ||
---|---|---|---|
Product: | POI | Reporter: | p.beauvoir |
Component: | XSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | regression | ||
Priority: | P2 | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | All | ||
Bug Depends on: | 62828 | ||
Bug Blocks: | |||
Attachments: | Test snippet that demonstrates the bug |
Description
p.beauvoir
2019-06-16 11:29:09 UTC
In 4.0.1 the CellReference constructor is this: public CellReference(Cell cell) { this(cell.getRowIndex(), cell.getColumnIndex(), false, false); } This means that _sheetName is null. And so the Sheet name is not prefixed to the cell. In 4.1.0 the CellReference constructor is this: public CellReference(Cell cell) { this(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), false, false); } This means that _sheetName is not null. And so the Sheet name is prefixed to the cell leading to the problem. Workaround: CellReference has this constructor which ensures that _sheetName is null: public CellReference(int pRow, int pCol, boolean pAbsRow, boolean pAbsCol) { this(null, pRow, pCol, pAbsRow, pAbsCol); } So call that constructor like this: XSSFSheet sheet; Cell cell; sheet.addIgnoredErrors(new CellReference(cell.getRowIndex(), cell.getColumnIndex(), false, false), IgnoredErrorType.NUMBER_STORED_AS_TEXT); Created attachment 36629 [details]
Test snippet that demonstrates the bug
This is likely caused by r1850210 which fixed bug #62828, seems Excel is inconsistent in which style of cell-reference is supported where, so we might need to use special formatting when writing this part of the XLSX file. Applied a fix via r1861817 which does not include the sheetName in references when setting ignored errors for cells. > Fixed
Nice. Thanks.
|