jgoddard Posted August 1, 2013 Share Posted August 1, 2013 Hi, I'm new to Ireport and I have a report that I am trying to export to Excel. It exports to pdf. fine, and even exported to excel until I added the following code in the expression editor of a field. $F{test_name}.equals("Install / Up / Down") ?$F{testresult_resulttext} :$F{test_name}.equals("Order Date") ?$F{testresult_resultdate} :("") When I run it I get the following error:Error Messagejava.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date Anybody else encounter something similar? Thanks in advance! Link to comment Share on other sites More sharing options...
lucianc Posted August 1, 2013 Share Posted August 1, 2013 It's a bug. It got fixed recently (at http://code.jaspersoft.com/svn/revision.php?repname=jasperreports&path=%2F&rev=6340&peg=6340) and will be included in the next release.As a workaround, you can have two text fields with print when expressions, one that prints testresult_resultdate and one that prints the text values.Regards,Lucian Link to comment Share on other sites More sharing options...
jgoddard Posted August 1, 2013 Author Share Posted August 1, 2013 Thanks- I found another workaround- I edited my code as below and it gave me the output needed. $F{test_name}.equals("Install / Up / Down") ? $F{testresult_resulttext} : $F{test_name}.equals("Order Date") ? new SimpleDateFormat("dd MMM yyyy").format($F{testresult_resultdate}) : ("") Link to comment Share on other sites More sharing options...
jgoddard Posted August 1, 2013 Author Share Posted August 1, 2013 Apologies, I didn't mean to post the comment on your response. Anyhow, thanks for the clarification. I found a workaround that gave me the output needed in excel- it is below. $F{test_name}.equals("Install / Up / Down") ?$F{testresult_resulttext} :$F{test_name}.equals("Order Date") ?new SimpleDateFormat("dd MMM yyyy").format($F{testresult_resultdate}):("") Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now