Monday, 9 September 2013

Apache Poi - Writing Foreign Characters To Excel 97/2003 (i.e. Chinese, Japanese, etc)

Apache Poi - Writing Foreign Characters To Excel 97/2003 (i.e. Chinese,
Japanese, etc)

I am trying to write some foreign character to an Excel 97/2003 file (i.e.
Chinese, Japanese, Korean, etc) and am having trouble. I have tried a lot
and nothing seems to work. Is it possible? My code for writing this cell
is below.
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Sample sheet");
...
HSSFRow row = sheet.createRow(0);
HSSFCell firstCell = row.createCell((short)0);
HSSFFont theFont = workbook.createFont();
theFont.setFontName("Arial Unicode MS");
HSSFCellStyle style = workbook.createCellStyle();
style.setFont(theFont);
firstCell.setCellStyle(style);
firstCell.setCellValue(firstColVal);

No comments:

Post a Comment