Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache poi maximum number of rows

I would like to know what is maximum number of row you can create with apache poi 3.8 and what is the maximum number you can create with apache poi 3.0 for generating excel files.

like image 591
Nomad Avatar asked Aug 14 '12 14:08

Nomad


3 Answers

Another SO user has provided a method to create many rows with POI 3.8. The maximum number of rows are limited by the maximum in the version of Excel you try to open the file in, as well. The int data type is returned by getRowNum (see API), so that could provide your "maximum", but going beyond the number of rows specified in the Excel version (~65k in 2003, 1,048,576 in 2007+) will mean data is lost and potential errors.

like image 93
Zairja Avatar answered Oct 21 '22 03:10

Zairja


just in case you want to catch it, this is the Exception that gets thrown.

java.lang.IllegalArgumentException: Invalid row number (65536) outside allowable range (0..65535)
like image 40
David Avatar answered Oct 21 '22 03:10

David


These limit values are provided by POI: https://poi.apache.org/apidocs/org/apache/poi/ss/SpreadsheetVersion.html

Specifically: SpreadsheetVersion.EXCEL97.getMaxRows() and SpreadsheetVersion.EXCEL2007.getMaxRows().

like image 23
Robert Fleming Avatar answered Oct 21 '22 04:10

Robert Fleming