poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hoppe, Sascha" <Sascha.Ho...@lineas.de>
Subject How to reuse cell styles?
Date Thu, 18 Dec 2008 14:04:41 GMT

Hi all,

usually I create cell styles for e.g. date cells this way:

HSSFCellStyle dateTimeStyle = workbook.createCellStyle();

If you do this for a large number of cells and you create a new instance of HSSFCellStyle
all the time,
you will run into a "too many data formats" or something similar when you open the .xls. file.

So usually I would use a cache-mechanism for the cell styles to reuse them and everything
will be fine.

But what if a write the workbook to disk and later reopen it. I have a new instance of HSSFWorkbook
now and would
like to append rows/cells to it. Of course I would like to reuse the cell styles that are
already in the workbook. But I could not find a way to access them. HSSFDataFormat.getFormat(String
format) won't do, because POI saves new DataFormats via index. How can my program "remember"
how the Styles where stored in the spreadsheet to reuse them on reopening and appending?

thanks for any clues.

Diese E-Mail kann vertrauliche und/oder rechtlich gesch├╝tzte
Informationen enthalten. Wenn Sie nicht der richtige Adressat sind
oder diese E-Mail irrt├╝mlich erhalten haben, informieren Sie bitte
sofort den Absender und vernichten Sie diese Mail. Das unerlaubte
Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail.
Any unauthorized copying, disclosure or distribution of the material
in this e-mail is strictly forbidden.

To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org

View raw message