hi,
i have only been using POI HSSF for a few weeks now so i am still a rookie.
In my application i am creating 4 spreadsheets from a template of 2
spreadsheets read in from a file. My first solution was to create a new
style for every cell like the following:
private HSSFCellStyle setStyle(HSSFWorkbook wb, HSSFCellStyle
templateStyle){
HSSFCellStyle style = wb.createCellStyle();
style.setAlignment( templateStyle.getAlignment() );
style.setBorderBottom( templateStyle.getBorderBottom() );
style.setBorderLeft( templateStyle.getBorderLeft() );
style.setBorderRight( templateStyle.getBorderRight() );
style.setBorderTop( templateStyle.getBorderTop() );
style.setBottomBorderColor( templateStyle.getBottomBorderColor() );
style.setDataFormat( templateStyle.getDataFormat() );
style.setFillBackgroundColor( templateStyle.getFillBackgroundColor() );
style.setFillForegroundColor( templateStyle.getFillForegroundColor() );
style.setFillPattern( templateStyle.getFillPattern() );
style.setHidden( templateStyle.getHidden() );
style.setIndention( templateStyle.getIndention() );
style.setLeftBorderColor( templateStyle.getLeftBorderColor() );
style.setLocked( templateStyle.getLocked() );
style.setRightBorderColor( templateStyle.getRightBorderColor() );
style.setTopBorderColor( templateStyle.getTopBorderColor() );
style.setVerticalAlignment( templateStyle.getVerticalAlignment() );
style.setWrapText( templateStyle.getWrapText() );
}
However, this is not the best solution as when you try and open a
spreadsheet in MS Excel it complains about having to many fonts and styles.
Therefore, my next solution was to simply copy the style from the template
cell into the newly created cell in the new spreadsheet like:
HSSFCellStyle originalStyle = oldCell.getCellStyle();
HSSFCellStyle style = originalStyle;
This does not work. From my research i have discovered that my above code
will work if you are copying a cellStyle from one cell to another in the
same sheet.
Does anyone have any suggestions to how i can copy one cellStyle from a
different workbook without having to create a style for every cell?
many thanks
mark
--
View this message in context:
http://www.nabble.com/HSSFCellStyle-help-tp18401553p18401553.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]