NumberFormatException on IF formula

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

    • Post Options:
    • Link

    Posted 26 October 2020, 2:07 am EST


    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(
    	at sun.misc.FloatingDecimal.parseDouble(
    	at java.lang.Double.parseDouble(
    	at java.lang.Double.valueOf(
    	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 Source)
    	at 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, 12:38 am EST


    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 27 October 2020, 8:49 pm 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.

    Thank you.

  • Posted 29 October 2020, 12:41 am EST


    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

  • Posted 29 October 2020, 3:07 am EST


    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:


    in the beginning of the programm.

    Thank you

  • Posted 29 October 2020, 7:34 pm EST


    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