Hi,

Could you please clarify me on reusing the existing CellStyle properties for
the new CellStyle and add new properties to the new CellStyle?

I have defined a Font by name "myFont" with the font properties.
Then, i created a CellStyle by name "myCellStyle" and set the font "myFont"
to this CellStyle, as given below.

Font myFont = workbook.createFont();
myFont.setFontHeightInPoints((short)10);
myFont.setFontName("Arial");

CellStyle myCellStyle = workbook.createCellStyle();
myCellStyle.setWrapText(true);
myCellStyle.setLocked(true);
myCellStyle.setFont(myFont);

Say if i have to create a new CellStyle which needs to have the properties
that are already defined in the above CellStyle "myCellStyle " and alongside
this i also want to add additional properties to the new CellStyle. In other
words, can i do the following:

//Associate the already defined CellStyle to the newCellStyle
CellStyle newCellStyle = myCellStyle ;

//Add more properties to newCellStyle
newCellStyle.setBorderTop(CellStyle.BORDER_THIN);
newCellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());
newCellStyle.setBorderRight(CellStyle.BORDER_THIN);
newCellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
newCellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
newCellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);

Please let me know your thoughts.

Regards,
Shankar
-- 
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Reusing-of-Fonts-and-CellStyles-tp3373245p3373245.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