Excel > JExcel API > How to add Italic Formatted Cell to Excel Spreadsheet
How to add Italic Formatted Cell to Excel Spreadsheet
Java Excel API is an open source java library to read, write and modify Excel spread sheets.
This requires the library jxl-2.6.12.jar to be in classpath.
The following example shows how to add italic formatted text to Excel Spread sheet.
// Create cell font and format
WritableFont cellFont = new WritableFont(WritableFont.COURIER, 16);
cellFont.setItalic(true);
WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
// Create the label, specifying content and format
Label label = new Label(1, 2, "ABCD", cellFormat);
Label label2 = new Label(1, 4, "XYZ", cellFormat);
sheet.addCell(label);
sheet.addCell(label2);
//Writes out the data held in this workbook in Excel format
workbook.write();
//Close and free allocated memory
workbook.close();
}