Jump to content
We've recently updated our Privacy Statement, available here ×

when amount is 0 how to set cell blank.


honeyani

Recommended Posts

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.00

Pattern 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

  • Replies 14
  • Created
  • Last Reply

Top Posters In This Topic

Thanks for your reply

Field type is double ..

I tried these ways ,also blank when null option is set to true

Double.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

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

I'm more confused

Cell 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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...