Bug 46312

Summary: Specified rowIndex 30 is outside the allowable range (0..30)
Product: POI Reporter: zzy9v4 <emilio.dolce>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: blocker    
Priority: P2    
Version: 3.2-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: excel template I start on
abstract base excel render service impl
concrete excel export class
General purpose utilities.

Description zzy9v4 2008-11-29 15:39:22 UTC
Created attachment 22964 [details]
excel template I start on

Trying to create an outlined excel spreadsheet I got the following exception. With the 3.1-FINAL everything work fine.

Consider that:
1) I start from an existing template (attached);
2) I need to report sum on top, then I used sheet.setRowSumsBelow(false) and sheet.setAlternativeExpression(false), but, by comment those lines the problem still occurs.

Caused by: 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)
	at it.mef.scai.shared.poiutils.ExcelUtil.inserisciValore(ExcelUtil.java:393)
	at it.mef.scai.paf.service.printexport.impl.GestioneFabbisogniExcelRenderServiceImpl.renderElement(GestioneFabbisogniExcelRenderServiceImpl.java:116)
	at it.mef.scai.paf.service.printexport.impl.GestioneFabbisogniExcelRenderServiceImpl.renderElement(GestioneFabbisogniExcelRenderServiceImpl.java:133)
	at it.mef.scai.paf.service.printexport.impl.GestioneFabbisogniExcelRenderServiceImpl.renderElement(GestioneFabbisogniExcelRenderServiceImpl.java:133)
	at it.mef.scai.paf.service.printexport.impl.GestioneFabbisogniExcelRenderServiceImpl.renderElement(GestioneFabbisogniExcelRenderServiceImpl.java:133)
	at it.mef.scai.paf.service.printexport.impl.GestioneFabbisogniExcelRenderServiceImpl.renderElement(GestioneFabbisogniExcelRenderServiceImpl.java:133)
	at it.mef.scai.paf.service.printexport.impl.ExcelTreeViewRenderServiceImpl.renderExcelTreeView(ExcelTreeViewRenderServiceImpl.java:58)
	... 78 more
Comment 1 zzy9v4 2008-11-29 15:40:41 UTC
Created attachment 22965 [details]
abstract base excel render service impl
Comment 2 zzy9v4 2008-11-29 15:41:12 UTC
Created attachment 22966 [details]
concrete excel export class
Comment 3 zzy9v4 2008-11-29 15:42:45 UTC
Created attachment 22967 [details]
General purpose utilities.
Comment 4 Josh Micich 2008-12-01 12:06:10 UTC
Fixed in svn r722206.

Next time can you try to simplify your example code that you upload.  This bug can actually be shown with just 4 lines of code:

HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
HSSFRow row = sheet.createRow(30);
row = sheet.createRow(30);  // << throws IllegalArgumentException


--
Adding a cell to the row before the second call to createRow() makes the bug go away.  So your code must have been creating rows multiple times before adding cells.  In any case, POI supports this usage now.