I want to set some values in the excel sheet using POI. These values must
have the required character formatting like bold, italics and underline.
Say, the value that I need to set in some cell in the excel could be
something like
italics plain boldItalics allThree<u> plain</u>
Whatever is there inside
.. should be set as italics
.. should be set as bold
<u>..</u> should be set as underline
I was trying to set this formatting by harcoding the indexes (for the time
being) using the following code
String str="italics plain boldItalics allThree<u> plain</u>";
HSSFWorkbook wb;
void func()
{
try{
File writeXcel=new File("C:/newOUT.xls");
FileOutputStream fileOut = new
FileOutputStream(writeXcel);
wb=new HSSFWorkbook();
HSSFSheet sheet=wb.createSheet("Sheet 1");
HSSFRow row=sheet.createRow(0);
HSSFCell cell=row.createCell((short)0);
HSSFRichTextString rts=new HSSFRichTextString(str);
HSSFFont font=wb.createFont();
font.setItalic(true);
font.setUnderline((byte)1);
font.setBoldweight((short)700);
rts.applyFont(0,5,font);
font.setItalic(false);
font.setUnderline((byte)0);
font.setBoldweight((short)400);
rts.applyFont(6,11,font);
font.setItalic(false);
font.setUnderline((byte)0);
font.setBoldweight((short)700);
rts.applyFont(12,16,font);
cell.setCellValue(rts);
wb.write(fileOut);
fileOut.close();
}catch(Exception e) {
e.printStackTrace();
}
}
But it seems it cannot be done, once the font is set it is set for
everything.
Can someone please tell me how to resolve this.
Thank You
--
View this message in context:
http://www.nabble.com/Set-character-formatting-in-Excel-using-POI-tf4262750.html#a12131092
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]