programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Jeanne Boyarsky
• Ron McLeod
• Paul Clapham
• Liutauras Vilda
Sheriffs:
• paul wheaton
• Rob Spoor
• Devaka Cooray
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Carey Brown
• Frits Walraven
• Tim Moores
Bartenders:
• Mikalai Zaikin

# if condition in formula in jxl

Greenhorn
Posts: 8
• Number of slices to send:
Optional 'thank-you' note:
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.

author
Posts: 3285
13
• Number of slices to send:
Optional 'thank-you' note:
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
• Number of slices to send:
Optional 'thank-you' note:
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
Posts: 3285
13
• Number of slices to send:
Optional 'thank-you' note:
You're welcome and I'm glad you solved it!

prinz reyes
Greenhorn
Posts: 8
• Number of slices to send:
Optional 'thank-you' note:
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

Greenhorn
Posts: 1
• Number of slices to send:
Optional 'thank-you' note:
For me this error disappeared after i removed static modifier from all DisplayFormat formats

Martijn Verburg
author
Posts: 3285
13
• Number of slices to send:
Optional 'thank-you' note:

Greenhorn
Posts: 3
• Number of slices to send:
Optional 'thank-you' note:

prinz reyes wrote: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!

I stumbled across the same problem: using , instead of ; worked, but i don't know why...
Now it gives me an error on the ^ symbol. Maybe is there another character to use instead of ^ ??

I have searched around if there is a syntax guide, but I haven't found anything =(

Saloon Keeper
Posts: 7589
177
• Number of slices to send:
Optional 'thank-you' note:
Post the formula that you are trying to evaluate.

I'm not sure why anyone is surprised that the parameters for Excel functions are separated by commas, not semicolons. The Excel documentation says exactly that: https://support.microsoft.com/en-us/office/using-functions-and-nested-functions-in-excel-formulas-3f4cf298-ded7-4f91-bc80-607533b65f02

maik miorandi
Greenhorn
Posts: 3
• 1
• Number of slices to send:
Optional 'thank-you' note:
Seems like it depens form your system settings:
https://www.excel-exercise.com/comma-or-semicolon-in-excel-formula/

For the ^ symbol, i have no clues
But I was able so replace it with the POWER function:
IF((H61-H60)>=0,H61-H60,(POWER(10,D61)+H61-H60))