Thank you for your help, David. Are you saying that I should not close the
style using
the cloneStyleFrom() method on the HSSFCellStyle object? This method is in
the
3.2-FINAL release I'm using and seems to be working.
Is it going to be removed in a later release?
Thanks,
David Fisher wrote:
>
> You can clone using something like:
>
> public static HSSFCellStyle cloneStyle(HSSFWorkbook wb,
> HSSFCellStyle src){
> HSSFCellStyle style = wb.createCellStyle();
> style.setFont(wb.getFontAt(src.getFontIndex()));
> style.setAlignment(src.getAlignment());
> style.setBorderBottom(src.getBorderBottom());
> style.setBorderLeft(src.getBorderLeft());
> style.setBorderRight(src.getBorderRight());
> style.setBorderTop(src.getBorderTop());
> style.setBottomBorderColor(src.getBottomBorderColor());
> style.setDataFormat(src.getDataFormat());
> style.setFillBackgroundColor(src.getFillBackgroundColor());
> style.setFillForegroundColor(src.getFillForegroundColor());
> style.setFillPattern(src.getFillPattern());
> style.setHidden(src.getHidden());
> style.setIndention(src.getIndention());
> style.setLeftBorderColor(src.getLeftBorderColor());
> style.setLocked(src.getLocked());
> style.setRightBorderColor(src.getRightBorderColor());
> style.setRotation(src.getRotation());
> style.setTopBorderColor(src.getTopBorderColor());
> style.setVerticalAlignment(src.getVerticalAlignment());
> style.setWrapText(src.getWrapText());
> return style;
> }
>
> Save all your new and different formats in an Array or HashMap.
>
> Add variations as you need them anything different in the style is
> another HSSFCellStyle object attached to the HSSFWorkbook. Use Clone
> to add new variations.
>
> To set the style of a cell just call
> HSSFCell.setCellStyle(HSSFCellStyle style).
>
> You can use HSSFWorkbook.getNumCellStyles() and
> HSSFWorkbook.getCellStyleAt(short idx) to retrieve the styles that are
> already in the file.
>
> Good luck.
>
> Regards,
> Dave
>
>
>
--
View this message in context:
http://www.nabble.com/Applying-a-data-format-to-a-style-for-one-cell-affects-other-cells--tp21362472p21379470.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]