cfsimplicity / spreadsheet-cfml

Standalone library for working with spreadsheets and CSV in CFML
MIT License
127 stars 36 forks source link

Avoid cellStyle duplication when formatting cells from a struct over multiple calls #320

Closed cfsimplicity closed 1 year ago

cfsimplicity commented 1 year ago

When supplying a struct of properties as the format argument to one of the formatting methods a new cellStyle object is created each time, whether or not one has already been created in the workbook for that format. Multiple formatting operations can therefore result in a large number of duplicate cellStyles added to the workbook's style table, which has limits.

This can be avoided by first creating the cellStyle object separately (using createCellStyle() and then passing that as the format argument instead of a struct.

But it would be an improvement if formats supplied as a struct could also be re-used as far as possible without having to prepare a cellStyle object.

This could be achieved by caching the cellStyle object created from a particular format struct so that it could be re-used over mutliple calls.

A new public method to clear the cache would also be useful.