https://issues.apache.org/bugzilla/show_bug.cgi?id=47169
Summary: HSSFSheet.shiftRows() causes record inconsistency:
Specified rowIndex 30 is outside the allowable range
(0..30)
Product: POI
Version: 3.2-FINAL
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: HSSF
AssignedTo: [email protected]
ReportedBy: [email protected]
When using HSSFSheet.shiftRows(), the RowRecordsAggregate seems to get
inconsistent with the ValueRecordsAggregate, resulting in the following
exception:
Exception in thread "main" java.lang.IllegalArgumentException: Specified
rowIndex 30 is outside the allowable range (0..30)
at
org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate.removeAllCellsValuesForRow(ValueRecordsAggregate.java:111)
at
org.apache.poi.hssf.record.aggregates.RowRecordsAggregate.removeRow(RowRecordsAggregate.java:120)
at org.apache.poi.hssf.model.Sheet.addRow(Sheet.java:677)
at org.apache.poi.hssf.usermodel.HSSFSheet.addRow(HSSFSheet.java:303)
at org.apache.poi.hssf.usermodel.HSSFSheet.createRow(HSSFSheet.java:206)
Code to reproduce:
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
sheet.createRow(30);
sheet.shiftRows(29, 29, 1, true, true);
sheet.createRow(30);
The first createRow() succeeds, the second fails. The first call can be left
out, leading to the same result.
As workaroud is not enough to create the target explicitely before shifting the
source row (as the reproducer code does), but you need to create a cell in this
row. The following code works:
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
sheet.createRow(30).createCell(0);
sheet.shiftRows(29, 29, 1, true, true);
sheet.createRow(30);
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]