Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Write character to excel using POI

 
Thomas Greene
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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



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 charcter). 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.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the javadoc,
there isn't a setValue method that takes a char as a parameter, so it must be being converted to a double and calling that method.

What happens if you say:



or, since the setValue(String) is deprecated,

 
Thomas Greene
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joel McNary:
According to the javadoc,
there isn't a setValue method that takes a char as a parameter, so it must be being converted to a double and calling that method.

What happens if you say:



or, since the setValue(String) is deprecated,



If I do this

cell.setCellValue(new HSSFRichTextString(String.valueOf(c)));

this is the error I get

The method setCellValue(double) in the type HSSFCell is not applicable for the arguments (HSSFRichTextString)
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the first one, with the argument as a String. Does that produce a similar error?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic