• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

if condition in formula in jxl

 
prinz reyes
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have this formula in my report using jxl..the formula works fine but then i have an error for the division of zero so i tried to use if.

here is a sample of my formula :

IF(C53=0; 0; C52/C53*100)

using this formula in excel is working but in my java code i am having an error:

Warning: Lexical error: (C53=0; 0; C52/C53*100) at char 6 when parsing formula (C53=0; 0; C52/C53*100) in cell Monthly SKU!E52


Does anyone have any idea on how to use the if condition in jxl?

Thanks.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not suer but it might be worth adding an extra () around the divisor e.g. (C53=0; 0; (C52/C53)*100)
 
prinz reyes
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply..i have found the solution..

instead of using ; i used comma(,) in the formula.

so instead of IF(C53=0; 0; C52/C53*100) it should be this way IF(C53=0, 0, C52/C53*100) .

i don't know how it happened but it worked!

thanks for your response!i really appreciate!
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome and I'm glad you solved it!
 
prinz reyes
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i still have another problem..

everytime i generate my report for the second time i am having an error..




i have read from other forums that i just have to make my WritableCellFormat as local variables and i tried it but it did not work.

do you have any idea?

thank you again
 
Dmitry Stoke
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For me this error disappeared after i removed static modifier from all DisplayFormat formats
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dmitry and welcome to Javaranch! Please see your PM for an important administrative matter .
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic