Bug 58005

Summary: Amount of CellStyles is still limited to 32K
Product: POI Reporter: Michael <mshlayen>
Component: SXSSFAssignee: POI Developers List <dev>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P2    
Version: 3.12-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Bug Depends on: 57880    
Bug Blocks: 58260    
Attachments: java code
Resulting xlsx file

Description Michael 2015-06-05 13:24:01 UTC
Created attachment 32796 [details]
java code

Amount of CellStyles is still limited to 32K. When you create large enough excel file, after reaching value of 32767 of CellStyles, next CellStyleID becomes negative (-32768).
Related bug # 57880 - for version 3.11 final. And it has not been fixed in the version 3.12 final, despite it is written in the release notes.
See attached java code and resulting xlsx file (what happens from the row 10923).

Same limit applies to Fonts.

PS: increasing limit to 64K is not a solution! Styles are stored in the ArrayList, and max size of it is MAX_INTEGER, which is 2,147,483,647
Comment 1 Michael 2015-06-05 13:24:44 UTC
Created attachment 32797 [details]
Resulting xlsx file
Comment 2 Dominik Stadler 2015-08-19 13:42:42 UTC
FYI, the general case up to 64k styles is fixed via bug 58260 now, it is not possible to support more than 64k of these because Excel itself limits the number of styles, files with more will be reported as corrupt by Excel! 

Also note the comments about proper re-using of styles in bug 58260, due to this usually not makes sense to have so many Fonts/Styles in the first place as you should re-use the created objects as much as possible!

I am closing this as DUPLICATE for now, please try with an upcoming nightly build or version 3.13-beta2 as soon as it becomes available and reopen the bug if this is still a problem for you.

*** This bug has been marked as a duplicate of bug 58260 ***