Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Tue Sep 07, 2021 6:39 am

Hi,
We're using Spire.Xls to convert xlsx files to pdf and we get an error java.lang.NumberFormatException: For input string: "."
Attached the input file and the code that returns the error.

Code: Select all
    public static void  save_to_pdf() {
        ByteArrayOutputStream  bts_out = new ByteArrayOutputStream();
        Workbook workbook = new Workbook();
        workbook.loadFromFile(".\\sources\\excel_to_pdf5.xlsx");
        workbook.getConverterSetting().setSheetFitToPage(true);
        workbook.saveToFile("res.pdf", FileFormat.PDF);
    }
Attachments
excel_to_pdf5.rar
(11.51 KiB) Downloaded 217 times

Kostegan
 
Posts: 6
Joined: Wed Sep 01, 2021 8:09 am

Tue Sep 07, 2021 9:21 am

Hi,

Thank you for your inquiry.
I tested your excel file with our latest version of Spire.XLS for Java Version:4.8.1, but did not reproduce your issue. If you were not using the latest version, please first give it a try. If the issue still exists after trying, please provide the following information for us to investigate further. Thanks in advance.
1) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
2) Your JDK version, such as 1.8.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1647
Joined: Wed Apr 07, 2021 2:50 am

Tue Sep 07, 2021 10:13 am

My test environment: Windows 7 Enterprise 64 bit, Russia, JDK 1.8.0
and we are also testing on the version Spire.XLS for Java Version:4.8.1

Kostegan
 
Posts: 6
Joined: Wed Sep 01, 2021 8:09 am

Wed Sep 08, 2021 9:03 am

Hello,

Thank you for your sharing.
I tested again in the same environment as yours, but still did not reproduce your problem. Here I attached my test demo for your reference, please have a try on your side. Looking forward to your feedback.

Sincerely,
Annika
E-iceblue support team
Attachments
excelToPDF.zip
(84.5 KiB) Downloaded 237 times
User avatar

Annika.Zhou
 
Posts: 1647
Joined: Wed Apr 07, 2021 2:50 am

Wed Sep 08, 2021 1:26 pm

Thank you for your help and for your test demo.
I tried it, but the error was repeated.
However, I found a solution that helped, I added a line before my code:
Locale.setDefault(new Locale("en", "US"));

Kostegan
 
Posts: 6
Joined: Wed Sep 01, 2021 8:09 am

Thu Sep 09, 2021 1:25 am

Hi,

Glad to hear that your issue has been solved. If you have other questions about using Spire.XLS in the future, please feel free to contact us.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1647
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS