aspose file tools*
The moose likes Other Open Source Projects and the fly likes if condition in formula in jxl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "if condition in formula in jxl" Watch "if condition in formula in jxl" New topic
Author

if condition in formula in jxl

prinz reyes
Greenhorn

Joined: Mar 30, 2009
Posts: 8
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

I'm not suer but it might be worth adding an extra () around the divisor e.g. (C53=0; 0; (C52/C53)*100)


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
prinz reyes
Greenhorn

Joined: Mar 30, 2009
Posts: 8
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

You're welcome and I'm glad you solved it!
prinz reyes
Greenhorn

Joined: Mar 30, 2009
Posts: 8
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

Joined: Jan 22, 2010
Posts: 1
For me this error disappeared after i removed static modifier from all DisplayFormat formats
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Dmitry and welcome to Javaranch! Please see your PM for an important administrative matter .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: if condition in formula in jxl
 
Similar Threads
Using JXL - Error encountered
Need help with Linear Equations.
Getting number of rows and column from Excel, using JXL library
Parsing using regular expression
JXL api 1.2.6 jar Formula ERROR