Monday, February 16, 2009

Apache Poi Turkish Character Support

Apache POI version 3.1 has got support for Turkish characters such as ('ş', 'ğ', 'İ', 'Ş', 'Ğ', 'ü', 'ç').

When I wanted to write a word into Excel file that is containing some of these characters, version 2.5.1 was not displaying it properly.

I updated the version of POI and the display problem resolved.


HSSFCell.ENCODING_UTF_16 includes required character support.
HSSFRow newRow = sheet.createRow((short)1);
newRow.createCell((short) 0).setCellValue("Başvuru Numarası");
HSSFCell cell0 = row.getCell((short) 0);
cell0.setCellType(HSSFCell.CELL_TYPE_STRING);
cell0.setEncoding(HSSFCell.ENCODING_UTF_16);

Required dependency for pom.xml file is :

 
   org.apache.poi
   poi
   3.1-FINAL
 

No comments:

Post a Comment