I'll suggest you to use of Apache POI Documentation.
I'll do some experiment using documentation and getting text formatting easily for Ms-Excel Sheet..
http://poi.apache.org/apidocs/org/apache/poi/xssf/usermodel/XSSFCellStyle.html
http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/BuiltinFormats.html
I was browsing through the API when I saw the DataFormat class and its hierarchy,
the BuiltinFormats class,
and the setDataFormat method of the CellStyle class.
So did some experimentation, and the code below seems to work!
XSSFCellStyle textFormatStyle = book.createCellStyle();
textFormatStyle.setDataFormat((short)BuiltinFormats.getBuiltinFormat("text"));
XSSFCell cell = row.createCell(columnIndex++);
cell.setCellStyle(textFormatStyle);
Now, once spreadsheet is created,
you can edit a cell, and when you tab out,
the format remains "text".
I having showing you another way with full example..
In which I'll show one effect further you can add as per your requirement...
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Style example");
HSSFFont font = workbook.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
HSSFCellStyle style = workbook.createCellStyle();
style.setFont(font);
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellValue("This is bold");
cell.setCellStyle(style);
font = workbook.createFont();
font.setItalic(true);
style = workbook.createCellStyle();
style.setFont(font);
row = sheet.createRow(1);
cell = row.createCell(0);
cell.setCellValue("This is italic");
cell.setCellStyle(style);
try {
FileOutputStream out = new FileOutputStream(new File("C:\\style.xls"));
workbook.write(out);
out.close();
System.out.println("Excel written successfully..");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
This code will generate bellow output :