Skip to main content
December 17, 2012
Question

SpreadsheetAddRows Limitation (ArrayIndexOutOfBoundsException)

  • December 17, 2012
  • 1 reply
  • 1344 views

I have a query that I am adding to a spreadhseet object that seems to error when the query has an unweildly amount of rows (18583 in this example). The exact error is as follows:

java.lang.ArrayIndexOutOfBoundsException: -32735

at java.util.ArrayList.get(ArrayList.java:324)

at org.apache.poi.hssf.model.WorkbookRecordList.get(WorkbookRecordList.java:50)

at org.apache.poi.hssf.model.Workbook.getExFormatAt(Workbook.java:787)

at org.apache.poi.hssf.usermodel.HSSFCell.getCellStyle(HSSFCell.java:901)

at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java:1727)

at coldfusion.excel.Excel.autoResize(Excel.java:1246)

at coldfusion.excel.Excel.autoResize(Excel.java:1240)

at coldfusion.excel.Excel.addRows(Excel.java:1214)

at coldfusion.runtime.CFPage.SpreadSheetAddRows(CFPage.java:7089) at coldfusion.runtime.CFPage.SpreadSheetAddRows(CFPage.java:7076)

Here's the relevant code:

<cfset xls = spreadsheetNew()>

<cfset spreadsheetAddRow(xls, arrayToList( qryTest.getMeta().getColumnLabels() ))>

<cfset SpreadsheetFormatRow(xls, {bold=true,fgcolor="brown",color="white"}, 1)>

<cfset SpreadsheetAddRows(xls, qryTest)>

<cfheader name="Content-Disposition" value="attachment; filename=#filename#">

<cfcontent variable="#spreadsheetReadBinary(xls)#" reset="yes" type="application/vnd.ms-excel">


This topic has been closed for replies.

1 reply

Inspiring
December 17, 2012

Does this also happen if you put maxrows="10" in your cfquery tag? 

December 17, 2012

It's been really hard to get a consistent result with this error. For a while, I was able to narrow the problem with the maxrows attribute and setting it to 17750. The problem however is that I can also set a scenario where it can produce a 18000 row XLS file when I commented out the head (the addrow/formatrow lines). Yet, when I reran the page with the same params, it would crash again with the same error. I have about ~40 xls files now on my drive with sizes ranging from 5,291KB (18000 rows without header code) to 635KB. This has been a headache all day to say the least.