NumberFormatException on IF formula

Posted by: ismael.zamora on 26 October 2020, 11:07 am EST

    • Post Options:
    • Link

    Posted 26 October 2020, 11:07 am EST

    Hello,

    I’m using the Document for Excel (Java) to fill a document generated in the client side with SpreadJS.

    Basically, the document creates two sheets, one where all the data will be putted, and another where the user can put some formulas to calculate the results based on the data in the first sheet.

    In the second sheet, there are two results, one that calculates a summe (=SUM(Data!B5,Data!B6)), and another that, based on this summe, gives a feedback about this value (=IF(B2<50000000,“good”,“bad”)), where B2 is the result of the first forumla.

    In the process where the Documents for excel put the needed values on the first sheet (“Data” sheet), and tries to save the excel to the Database, it throws a java.lang.NumberFormatException: For input string: “1,2868407174014E7”. This number is the one calculated in the B2 cell, and it raises this exception when trying to compare in the IF.

    the complete stacktrace is:

    For input string: "1,2868407174014E7"
    java.lang.NumberFormatException: For input string: "1,2868407174014E7"
    	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
    	at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    	at java.lang.Double.parseDouble(Double.java:538)
    	at java.lang.Double.valueOf(Double.java:502)
    	at com.grapecity.documents.excel.f.aR.b(Unknown Source)
    	at com.grapecity.documents.excel.f.S.a(Unknown Source)
    	at com.grapecity.documents.excel.f.S.a(Unknown Source)
    	at com.grapecity.documents.excel.k.i.n.e(Unknown Source)
    	at com.grapecity.documents.excel.j.k.e(Unknown Source)
    	at com.grapecity.documents.excel.f.a.h(Unknown Source)
    	at com.grapecity.documents.excel.k.f.d.a(Unknown Source)
    	at com.grapecity.documents.excel.j.k.a(Unknown Source)
    	at com.grapecity.documents.excel.j.f.b(Unknown Source)
    	at com.grapecity.documents.excel.j.h.a(Unknown Source)
    	at com.grapecity.documents.excel.g.f.u(Unknown Source)
    	at com.grapecity.documents.excel.B.ao.e(Unknown Source)
    	at com.grapecity.documents.excel.B.ao.b(Unknown Source)
    	at com.grapecity.documents.excel.l.b.P.a(Unknown Source)
    	at com.grapecity.documents.excel.l.b.P.a(Unknown Source)
    	at com.grapecity.documents.excel.l.b.P.a(Unknown Source)
    	at com.grapecity.documents.excel.l.b.O.a(Unknown Source)
    	at com.grapecity.documents.excel.l.b.O.a(Unknown Source)
    	at com.grapecity.documents.excel.Workbook.toJson(Unknown Source)
    
  • Posted 27 October 2020, 9:38 am EST

    Hello,

    Can you please share a working application so that we can investigate this issue further. It’s difficult to debug the issue without looking at the code.

    Hence, please provide us with your working sample and also let us know the version of GcExcel JAVA you are using. We will look into this issue thereon.

    Thanks,

    Reeva

  • Posted 28 October 2020, 5:49 am EST

    I’m using the 3.2.3 version of the Documents for Excel, Java.

    I attach a test code, with the excel that I create using the SpreadJS framework, and the exception that occurs.

    xchange.zip

    Thank you.

  • Posted 29 October 2020, 9:41 am EST

    Hello,

    We used the code from your sample application and we are not getting any exception at our end using GcExcel version 3.2.3 and we are getting this output in console (text file attached).

    Also we didn’t get any excel file that was created using SpreadJS as you said at your end.

    Request you to please let us know what are we missing to replicate the issue at our end and also specify exact steps to follow.

    I am attaching the sample for your reference.

    Thanks,

    Reeva

    NumberFormaException_Forum.zip

    Console-Output.zip

  • Posted 29 October 2020, 12:07 pm EST

    Hello,

    I just did a quick test, and I found the issue. It happens that if I have setted the Local language to something different of English (Spanish, in my case) the exception occurs. The problem has been solved by adding this line:

    java.util.Locale.setDefault(java.util.Locale.ENGLISH);
    

    in the beginning of the programm.

    Thank you

  • Posted 30 October 2020, 4:34 am EST

    Hello,

    We are glad to know that your issue has been resolved.

    Thanks,

    Reeva

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels