• Post Reply Bookmark Topic Watch Topic
  • New Topic
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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

if condition in formula in jxl

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome and I'm glad you solved it!
 
prinz reyes
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For me this error disappeared after i removed static modifier from all DisplayFormat formats
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dmitry and welcome to Javaranch! Please see your PM for an important administrative matter .
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 =(
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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))
instead of
IF((H61-H60)>=0,H61-H60,(10^D61)+H61-H60))

I wonder if there is any formula syntax guide around...
 
reply
    Bookmark Topic Watch Topic
  • New Topic