mjul / docjure

Read and write Office documents from Clojure
MIT License
620 stars 129 forks source link

Reuse similar-looking CellStyles #105

Open orestis opened 1 year ago

orestis commented 1 year ago

A common issue when using Excel is that there is a limit of 64000 styles in an Excel document.

This means that at some point you need to reuse styles, you can't just be creating the same cell style and applying it. It gets worse if you're mutating already existing cell styles, e.g. to add a number format etc.

Apache POI has a CellUtil class that supposedly handles this, but during my testing it seemed buggy. What it does essentially is to just create a data structure out of a CellStyle, and iterate through the styles on the workbook to see if a class already exists.

Are you interested in adding a new function like (add-cell-style! cell style-map) that would do the same? Since create-cell-style! already accepts a data structure, the new function would support also generating the same data structure from an existing CellStyle.

orestis commented 1 year ago

(BTW I'm happy to provide a PR for this too!)