honeyani Posted October 16, 2008 Share Posted October 16, 2008 I have generated excel report using Jasper (ireport tool).On final generated excel sheet ,if amount is 0- blank cell should be displayed ,i'm getting $0.00Pattern applied to the cell is $#,##0.00;[Red]($#,##0.00) ,blank when null option is checked. why this issue ,hope value is returned as 0 hence 0 is formatted as per the pattern and displayed as $0.00, but only blank space should be set to the cell .how to establish this?Please guide to fix this issue.waiting for your eply.Thx,Ani Link to comment Share on other sites More sharing options...
shrije Posted October 16, 2008 Share Posted October 16, 2008 using an expression set zero to null value. and use "blank when null" option in text box. Link to comment Share on other sites More sharing options...
honeyani Posted October 17, 2008 Author Share Posted October 17, 2008 I have coded expression to set "0" or " " when value doesn't exists.Have also checked blank when null option.Still i get $0.00 displayed ,for 0 value the pattern gets applied and displayed.Anyother options to follow up? Link to comment Share on other sites More sharing options...
honeyani Posted October 17, 2008 Author Share Posted October 17, 2008 Thanks for your replyField type is double ..I tried these ways ,also blank when null option is set to trueDouble.valueOf($F{BUDGETADJ}.length()==0?" " :$F{BUDGETADJ}.trim())Double.valueOf($F{BUDGETADJ}.length()==0?"0 " :$F{BUDGETADJ}.trim())Double.valueOf($F{BUDGETADJ}.length()==0?null :$F{BUDGETADJ}.trim())please guide to fix this..waiting for your reply at the earliest.. Link to comment Share on other sites More sharing options...
shrije Posted October 17, 2008 Share Posted October 17, 2008 Two things you can try. Just hard code the 'null' value and check if you are getting blank. This will tell u that the solution works(i know it works). Second try ($F{BUDGETADJ}.length()==0?null :Double.valueOf($F{BUDGETADJ}.trim())) Double.value must be intialising from null to zero again. Link to comment Share on other sites More sharing options...
honeyani Posted October 17, 2008 Author Share Posted October 17, 2008 I'm more confusedCell type is set as double ,Actual expression is as below :Double.valueOf(($F{BUDGETADJ}.indexOf("-")!=-1?"-"+($F{BUDGETADJ}.substring(0,$F{BUDGETADJ}.indexOf("-"))).trim():($F{BUDGETADJ}.length()==0?null:$F{BUDGETADJ}.trim())))value exists as 10000.00 - ,so this expression checks for - sign at the end and brings it to front ,second condition i check for empty values..can you suggest how to update this expression?waitign for reply ASAP... Link to comment Share on other sites More sharing options...
honeyani Posted October 17, 2008 Author Share Posted October 17, 2008 Thanks for your reply. My opinion is Default value for string is null - 'blank if null' option works if the field type is String.I tested the same . But for our report cell type is set as double for some reason,default value for double will be 0.00 ,hence the pattern gets applied to it and displayed as $0.00 ,am i right in my view? So I think now i should update my query as ,In iReport tool for Double cell type is it possible to set blank when value is 0.00 ? Any idea? Link to comment Share on other sites More sharing options...
shrije Posted October 17, 2008 Share Posted October 17, 2008 It works for Double as well. I can see blank value inspite of a pattern applied. I used this expression Double.valueOf((double)100000.0) and null. It worked for me. It showed pattern when value was present and blank when null. Link to comment Share on other sites More sharing options...
shrije Posted October 17, 2008 Share Posted October 17, 2008 Replace $F{BUDGETADJ}.length() by $F{BUDGETADJ}.trim.length() nin yr expr Link to comment Share on other sites More sharing options...
honeyani Posted October 17, 2008 Author Share Posted October 17, 2008 i tried after trim() still i get $0.00 Can you send across the exact expression you tried with for double. Link to comment Share on other sites More sharing options...
shrije Posted October 17, 2008 Share Posted October 17, 2008 The resilting value of your expression would be as shown in the attachement Link to comment Share on other sites More sharing options...
shrije Posted October 17, 2008 Share Posted October 17, 2008 did it work finally Link to comment Share on other sites More sharing options...
honeyani Posted October 20, 2008 Author Share Posted October 20, 2008 hi,Thanks for your reply and guidance..I fixed it now,it works...Thanks,Ani Link to comment Share on other sites More sharing options...
shrije Posted October 20, 2008 Share Posted October 20, 2008 Waht does the expression look like now ? If that is the change that fixed it. Waht way did it fix otherwise ? Link to comment Share on other sites More sharing options...
honeyani Posted October 20, 2008 Author Share Posted October 20, 2008 Hi ,My expression is the same...it returns 'null' when value is empty for that field in XML data source.Option 'Blank when null' is set to true. As when the value it null it is set to blank as the option says..My Excel sheet is now with blank cell when value from XML file is empty or 0 or 0.00.Little i updated my expression to check for all these three values and set to null..It works fine...To Conclude :iReport tool supports setting blank to field value in Excel when value is null/0/0.00/<empty space>.We have to play around with expressions...:) 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