Bug 63613 - The maximum number of Cell Styles was exceeded. You can define up to 64000 style in a .xlsx Workbook Issue
Summary: The maximum number of Cell Styles was exceeded. You can define up to 64000 st...
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.17-FINAL
Hardware: PC All
: P2 critical (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-26 14:44 UTC by Ashok Mahendran
Modified: 2019-07-27 09:42 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ashok Mahendran 2019-07-26 14:44:30 UTC
I have tried to export large number of data . I am using 3.15 Version applying style to cells like Text, Date, Number.

Throwing below error 

java.lang.IllegalStateException: The maximum number of Cell Styles was exceeded. You can define up to 64000 style in a .xlsx Workbook
	at org.apache.poi.xssf.model.StylesTable.createCellStyle(StylesTable.java:789)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.createCellStyle(XSSFWorkbook.java:715)
	at org.apache.poi.xssf.streaming.SXSSFWorkbook.createCellStyle(SXSSFWorkbook.java:868)
Comment 1 PJ Fanning 2019-07-26 17:10:25 UTC
POI 3.15 is no longer maintained. Could you try POI 4.1.0?

Could you provide a test case if this issue appears in POI 4.1.0 too?
Comment 2 Dominik Stadler 2019-07-27 09:42:15 UTC
I think this is "as expected". Microsoft Excel limits the number of styles in Excel files and thus POI also limits them. The Exception tells you that you try to create more styles than possible.

Usually this indicates incorrect usage of the API. You need to re-use styles and not create fresh ones for each and every cell, then also performance in both Apache POI and Excel itself may be better as much less styles need to be handled when opening/saving the file.