You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by thomas908 <an...@hcl.in> on 2007/07/12 13:23:53 UTC

Write character to excel using POI

I have hex code of a special character.

Say, String str="2122";

I want to write the character corresponding to this hex code to an excel
file (using POI).

This is my code

       public class Test
    {
     
          void func() {
                
                String str="2122";
                
                char c=(char)Integer.parseInt(str, 16);
                 System.out.println(c);
                 try{
                           File writeXcel=new File("C:/new.xls");
                            FileOutputStream fileOut = new
FileOutputStream(writeXcel);
                            HSSFWorkbook wb=new HSSFWorkbook();
                            HSSFSheet sheet=wb.createSheet();
                            HSSFRow row=sheet.createRow(0);
                            HSSFCell cell=row.createCell((short)0);
                      
                            cell.setCellValue(c);
                            wb.write(fileOut);
                            fileOut.close();
                 }catch(Exception e) {
                       e.printStackTrace();
                 }
                 
          }
          public static void main(String[] args)
          {
                Test hc=new Test();
                hc.func();
     
          }
     
    }


Problem is that in the console I am getting the correct character. But when
it is written to the excel sheet, i get the corresponding decimal value
(rather than the character). So the value that i get in the excel sheet is
8482.
Please tell me how can I get the character in the excel sheet.

-- 
View this message in context: http://www.nabble.com/Write-character-to-excel-using-POI-tf4067473.html#a11557884
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org