Excel 2003 has 64K row limit and I can export up to 64K rows using POI, but only if I don't use sheet.autoSizeColumn(i) method. Here's a simple example that leads to this problem: try to create a sheet with over 33K rows (I used 34K) and a single column. When data is written, call sheet.autoSizeColumn to auto-fit the column and it breaks with this exception. java.lang.ArrayIndexOutOfBoundsException: -32732 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:906) at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java:1727) at org.apache.poi.hssf.usermodel.HSSFSheet.autoSizeColumn(HSSFSheet.java:1662) When there are more columns it breaks even sooner than that. My usecase has ~50 columns and it breaks even with 2K rows. It looks like it uses short int data type and it goes out of range. Let me know if you need more info. Cheers
Can you try with a recent svn nightly build? Only there have been some auto size fixes since 3.6, and you might find it's already been sorted
Just tried with poi-3.8-beta1-20110302 and it still fails :(
poi-3.8-beta1-20110302 fails, but with a different exception! You are creating too many cell styles. The maximum number of cell styles in a workbook is 4000, see http://office.microsoft.com/en-us/excel-help/excel-specifications-and-limits-HP005199291.aspx Cell Styles must be shared. Do not create per-cell, otherwise you will get a “Too many styles” error in Excel when opening your workbook. Think of Cell Styles like CSS and create them like that. http://poi.apache.org/faq.html#faq-N100EF Yegor *** This bug has been marked as a duplicate of bug 49188 ***