Sharvani
Sharvani

Reputation: 111

java.lang.IllegalStateException: The maximum number of Cell Styles was exceeded. You can define up to 64000 style in a .xlsx Workbook

I am working on a project where I have to apply different colors on each cell on multiple rows. However, I get the below exception where max amount is reached. Could you please on how to proceed and let me know if we can extend the cell styles to more than 64000.

Exception: java.lang.IllegalStateException: The maximum number of Cell Styles was exceeded. You can define up to 64000 style in a .xlsx Workbook

Upvotes: 5

Views: 19837

Answers (1)

Mukesh Kumar
Mukesh Kumar

Reputation: 661

Microsoft Excel limits the number of styles in an Excel file and thus POI also limits them. The Exception indicates that you are creating more styles than possible for a single Excel file.

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 fewer styles need to be handled when opening/saving the file.

Upvotes: 12

Related Questions