Bug 57880 - Writing negative cellStyleIndex into sheet1.xml
Summary: Writing negative cellStyleIndex into sheet1.xml
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.11-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Blocks: 57884 58005
  Show dependency tree
Reported: 2015-05-01 15:26 UTC by Michael
Modified: 2017-09-10 08:02 UTC (History)
0 users

Java code (42.02 KB, text/x-java)
2015-05-01 15:26 UTC, Michael
template xlsx file (11.06 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2015-05-01 15:27 UTC, Michael

Note You need to log in before you can comment on or make changes to this bug.
Description Michael 2015-05-01 15:26:31 UTC
Created attachment 32710 [details]
Java code

When creating large excel file and creating more than 32,767 (MAX VALUE for short) cellStyles, POI writes into sheet1.xml file negative values for that index: next after 32,767 comes -32,768, then -32,767, -32,766, etc...
This creates corrupted xlsx file.
Comment 1 Michael 2015-05-01 15:27:20 UTC
Created attachment 32711 [details]
template xlsx file
Comment 2 Nick Burch 2015-05-03 08:11:49 UTC
In r1677371 I've added fixes for data formats and cell styles > 32,767 in XSSF, along with a (slightly slow) unit test showing that things work fine

If I've missed some bit of your use case in the unit test, and some part of the problem still remains, please re-open this bug and attach an updated unit test showing what remains
Comment 3 Javen O'Neal 2015-12-28 09:08:48 UTC
The xlsx file may be corrupted if you create too many data formats. Excel only supports between 200-250 data formats. See bug 58775.