POI HSSF Cell Style question

R

Rob Y.

In Apache POI-HSSF, it seems like the HSSFCellStyle is global to the
workbook. I assume that means that in order to, say, color cells as
you add them, creating a new HSSFCellStyle for each would be hugely
inefficient.

But if my data source makes it difficult to know all possible cell
styles upfront (especially, since cell styles are combinations of
font, color, border, etc), how can I know when I need to create a new
one? I suppose I could keep a table of all the style parameter
combinations I've encountered, but doesn't the library already do
this?

I guess my bottom-line question: is there a way to query your
workbook to find out whether a cell style you want to use matches one
that's already in the workbook and to use that instead? Or, put
another way, does Excel allocate separate cell style records for each
cell, or does it dynamically figure out which styles are unique and
only store them when it needs to? If I were to create a spreadsheet
where all the green cells shared a single cell style, would a user
changing a single cell's color end up changing them all?

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top