java - Setting a part of the cell contents to Underline using apache poi? -


i working on program in have set cell value in excel sheet

"this underlined text".

it can bold,italic or underline.

i using poi 3.9 , netbeans, please me this

thanks in advance.

try following:

public static void differentfonttypeinsamecell(){     workbook wb = new hssfworkbook();     sheet sheet = wb.createsheet("testsheet");     cell cell = sheet.createrow(0).createcell(0);     font underlinefont = wb.createfont();     underlinefont.setunderline(hssffont.u_double);     font boldfont = wb.createfont();     boldfont.setboldweight(font.boldweight_bold);     font italicfont = wb.createfont();     italicfont.setitalic(true);     cellstyle style = wb.createcellstyle();     style.setfont(underlinefont);     cell.setcellstyle(style);     richtextstring richstring = new hssfrichtextstring("underline, bold, italic");     richstring.applyfont(11, 15, boldfont);     richstring.applyfont(17, 23, italicfont);     cell.setcellvalue(richstring); } 

will enter image description here

you can change font colors in same way... refer here


Comments