Foud it but it sis only available for the HSSF stream. Just for completeness
sake, the class is called HSSFOptimiser and the method optimiseCellStyles()
which - to quote the java doc - "Goes through the Wokrbook, optimising the
cell styles by removing duplicate ones."

Not suggesting that this is a good idea but you could simply clone the style
from each and every cell and then optimise the workbook. Not a good idea as
that is likely to be very slow.

Thinking further about my previous post, have you tried this;

Clone the styles from you old workbook.
As you create the clone write it away to a HashTable that is keyed on the
index of the old style (you would need to convert integers into Strings
using String.valueOf() to create the key).

Now as you copied the cell from the old worksheet you could get its styles,
get the index of that style, convert this to an String, use that to read the
HashTable and get the new style object to apply to the copy.

Might work but it does force you to do some of the work of managing the
styles as Christian indicated in his post.

--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/How-do-I-copy-cell-styles-tp5615723p5618204.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to