Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.apache.poi.ss.usermodel.CellStyle are not reused #5

Open
thomasthebaker opened this issue Aug 14, 2015 · 2 comments
Open

org.apache.poi.ss.usermodel.CellStyle are not reused #5

thomasthebaker opened this issue Aug 14, 2015 · 2 comments

Comments

@thomasthebaker
Copy link

From reading the code, I think you end up generating a new CellStyle object every time a cell is added to the workbook. There is a limit of 64000 unique cell formats per workbook (https://support.office.com/en-nz/article/Excel-specifications-and-limits-16c69c74-3d6a-4aaf-ba35-e6eb276e8eaa).

I think if the CellStyles aren't being reused then it would be worth adding caching so that a Style object will only create a CellStyle on the workbook once. Then if you maintain a reference to a Style object then the same CellStyle instance from the workbook will be applied to each cell that uses the Style instance.

I'm happy to submit a pull request for this if you agree on my analysis.

@tobyweston
Copy link
Owner

Good idea, thanks. It'd be interesting to try and create a test to demonstrate it 🙈 !!

Happy to accept pull requests.

@tobyweston
Copy link
Owner

I wonder if we can cache it here:

return new ReplaceExistingStyle(border, format, alignment, fontSize, fontColour, fill);

or

return new ReplaceExistingStyle(border, format, alignment, fontSize, fontColour, fill);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants