This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Excel Writing Using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Excel Writing Using Java" Watch "Excel Writing Using Java" New topic
Author

Excel Writing Using Java

A.S. HariLal
Ranch Hand

Joined: Oct 24, 2007
Posts: 31
Dear Friends,
When I try to write data to excel i got the following exception
org.apache.poi.hssf.usermodel.HSSFCell cannot be cast to java.lang.String

code is like

If there is any solution, please help me
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12754
    
    5
headerCell.setCellValue(new HSSFRichTextString(titleArray.get(cnt))); // Exception is happening here


What is the type of titleArray?
A.S. HariLal
Ranch Hand

Joined: Oct 24, 2007
Posts: 31
String is the type
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Another step to take is to split the line into:



Is it now clear exactly where the error is and what it is?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
A.S. HariLal
Ranch Hand

Joined: Oct 24, 2007
Posts: 31
Thank you...now it's working
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

You're welcome!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Excel Writing Using Java
 
Similar Threads
opening the excel sheet from servlet
creating enlarged image in excel using java
Exporting some data to excel
Issue with Download using ZipOutputStream
Excel steps -