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.
Asked
Active
Viewed 3.3k times
6
-
1We encourage you to [research your questions](http://stackoverflow.com/questions/how-to-ask). If you've [tried something already](http://whathaveyoutried.com/), please add it to the question- if not, research and attempt your question first, and then come back. – David B Aug 14 '12 at 14:25
-
1@David B, Peter Lawery. Guys, I did google before posting a question. I didn't find the answers, for the maximum rows, that's why i posted the question. – Nomad Aug 14 '12 at 14:31
-
1@Nomad You should add the result of your research in your question. – Luiggi Mendoza Aug 14 '12 at 14:41
3 Answers
12
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.
-
1@Nomad they're trying to help but not just you, you're not the only person that could have this problem, so it should help other people from here on. If you read the [FAQ](http://stackoverflow.com/faq) you could have a better understanding behind their "critics". – Luiggi Mendoza Aug 14 '12 at 19:35
6
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()
.

Robert Fleming
- 1,337
- 17
- 13
1
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)

David
- 61
- 1
- 2
-
That's for HSSF Workbook. For XSSF one limit is approximately 1M rows – dimirsen Z Oct 23 '18 at 10:24