Hi all,
usually I create cell styles for e.g. date cells this way:
HSSFCellStyle dateTimeStyle = workbook.createCellStyle();
dateTimeStyle.setDataFormat(format.getFormat("h:mm:ss"));
dateTimeStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
cell.setCellStyle(dateTimeStyle);
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: [email protected]
For additional commands, e-mail: [email protected]