This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Write character to excel using POI

 
Ranch Hand
Posts: 132
  • 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.
 
Bartender
Posts: 1840
Eclipse IDE Ruby Java
  • 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: 132
  • 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 Ruby Java
  • 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?
 
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!