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 Mar 15, 2022 1:35 am

Hi there

I am generating an excel-template report using the SpireXLS for Java workbook.saveToStream() method. When I generate the report as excel it works fine, but when I generate it as PDF it fails.

The excel-template contains images, and when I remove the images then it generates fine as PDF. So the issue seems to be directly to do with the images being in the excel file.

I am running as an Azure App Service, with my Java application running in a Tomcat 9.0 instance. When I run locally on my Windows machine the report generates correctly in both excel and PDF format. So the issue is also related to running in Azure.

I have tried different browsers but this does not make a difference.

I have certain required font files stored in a file directory within my app service home folder - these are only needed when generating the report as PDF. This does not seem to be causing an error and the fonts are working fine.

It seems to be a combination of pdf, images and Azure causing the error but I cannot figure out why, or what to do to fix it.

I have attached a very simple excel-template which fails ... the stack trace is not very helpful (I assume the class names are obfuscated):

java.lang.NoClassDefFoundError: Could not initialize class com.spire.xls.packages.sprmlg
at com.spire.xls.packages.sprbgg.<init>(Unknown Source)
at com.spire.xls.packages.sprbgg.<init>(Unknown Source)
at com.spire.xls.packages.sprzgg.spr‡┘(Unknown Source)
at com.spire.xls.packages.sprogf.spr⁆⌬(Unknown Source)
at com.spire.xls.packages.sprsrj.spr∮╃(Unknown Source)
at com.spire.xls.packages.sprzhj.sprㆁ╁(Unknown Source)
at com.spire.xls.packages.sprzhj.spr┳╂(Unknown Source)
at com.spire.xls.packages.sprzhj.spr┴╂(Unknown Source)
at com.spire.xls.packages.sprzhj.spr⅙╁(Unknown Source)
at com.spire.xls.packages.sprzhj.spr╁╂(Unknown Source)
at com.spire.xls.packages.sprzhj.spr┞╂(Unknown Source)
at com.spire.xls.packages.sprnqp.spr▀┩(Unknown Source)
at com.spire.xls.packages.sprdoj.spr⅕╁(Unknown Source)
at com.spire.xls.packages.sprdoj.spr⌻≌(Unknown Source)
at com.spire.xls.core.spreadsheet.XlsWorkbook.spr⌻≌(Unknown Source)
at com.spire.xls.Workbook.spr◍╆(Unknown Source)
at com.spire.xls.Workbook.saveToStream(Unknown Source)
at nz.co.dairyinsight.dairydata.report.ExcelReportProcessingService.formatWorkbookForDownload(ExcelReportProcessingService.java:461)

I have checked and class sprmlg is present in the jar file, but can't be initialised and not sure why. I am using the latest version of SpireXLS for Java - 5.3.1.

Also attached is a screenshot of the Java code I'm running.
Attachments
Images Issue.zip
(138.11 KiB) Downloaded 104 times

karenv_datacom
 
Posts: 15
Joined: Thu Apr 08, 2021 2:09 am

Tue Mar 15, 2022 10:14 am

Hello,

Thank you for your inquiry.
I will investigate your issue and give you feedback as soon as possible. Thanks for your understanding.
Also, please provide the JDK version you are using for us to investigate further.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Wed Mar 16, 2022 9:23 pm

Hi Annika

Many thanks, any help would be much appreciated. We are using JDK8.

If you're able to check what happens when the class com.spire.xls.packages.sprmlg initializes, and what during that initialization could go wrong, that would help to get some direction into what might be causing the issue. Unfortunately there is no line number in the stack trace, but we know the error occurs upon initialization of that class.

java.lang.NoClassDefFoundError: Could not initialize class com.spire.xls.packages.sprmlg
at com.spire.xls.packages.sprbgg.<init>(Unknown Source)
at com.spire.xls.packages.sprbgg.<init>(Unknown Source)
at com.spire.xls.packages.sprzgg.spr‡┘(Unknown Source)
at com.spire.xls.packages.sprogf.spr⁆⌬(Unknown Source)
at com.spire.xls.packages.sprsrj.spr∮╃(Unknown Source)
at com.spire.xls.packages.sprzhj.sprㆁ╁(Unknown Source)
at com.spire.xls.packages.sprzhj.spr┳╂(Unknown Source)
at com.spire.xls.packages.sprzhj.spr┴╂(Unknown Source)
at com.spire.xls.packages.sprzhj.spr⅙╁(Unknown Source)
at com.spire.xls.packages.sprzhj.spr╁╂(Unknown Source)
at com.spire.xls.packages.sprzhj.spr┞╂(Unknown Source)
at com.spire.xls.packages.sprnqp.spr▀┩(Unknown Source)
at com.spire.xls.packages.sprdoj.spr⅕╁(Unknown Source)
at com.spire.xls.packages.sprdoj.spr⌻≌(Unknown Source)
at com.spire.xls.core.spreadsheet.XlsWorkbook.spr⌻≌(Unknown Source)
at com.spire.xls.Workbook.spr◍╆(Unknown Source)
at com.spire.xls.Workbook.saveToStream(Unknown Source)
at nz.co.dairyinsight.dairydata.report.ExcelReportProcessingService.formatWorkbookForDownload(ExcelReportProcessingService.java:461)

karenv_datacom
 
Posts: 15
Joined: Thu Apr 08, 2021 2:09 am

Thu Mar 17, 2022 7:28 am

Hello,

Thanks for your feedback.
I tested your Excel file, deployed the project to Azure, and indeed reproduced the issue you mentioned. I have logged the issue into our bug tracking system with the ticket number SPIREXLS-3750. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Thu Mar 17, 2022 8:16 am

Thanks Annika. Is there a way for me to track the progress of the ticket?

Is there any workaround you can suggest - aside from removing the images from the excel file of course - as this issue is holding up a major release of our application?

karenv_datacom
 
Posts: 15
Joined: Thu Apr 08, 2021 2:09 am

Thu Mar 17, 2022 10:20 am

Hello,

You are welcome.
I'm sorry that we don't have the status of the issue public, so you can't view the issue's progress. I have posted your situation to our Dev Team and asked them to deal with it as soon as possible. I will let you know as soon as there are any major updates. But currently I don't have a good solution for you. Sorry for the inconvenience caused again.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Tue Mar 22, 2022 7:55 am

Hi Annika

Please note that we hold an OEM Developer License, the support period for which expires 29th June 2022. I can provide proof of this if required.
Our sole reason for purchasing and using SpireXLS for Java is to be able to convert our excel-spreadsheet reports to PDF. This functionality not working, albeit in our specific deployment environment, is a major concern for us and as previously mentioned is holding up a major release of our application - adding the functionality for users to download reports as PDF.

Is it possible to please give the ticket raised the highest priority? Also, will you keep me informed of any updates on it or how will I know if/when it is being looked at and what the resolution is?

Many thanks
Karen

karenv_datacom
 
Posts: 15
Joined: Thu Apr 08, 2021 2:09 am

Tue Mar 22, 2022 9:05 am

Hello,

Thanks for following up.
I have found your purchase record. I've upgraded the issue SPIREXLS-3750 to a superlative A (A>B>C), and our development team is working hard to investigate the issue. Once there is any update or finding, I will inform you immediately.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Tue Mar 22, 2022 9:49 am

Hello,

Thanks for your patience.
I tested your excel file with the newly released Spire.XLS for Java Version: 5.3.3 and found that the issue SPIREXLS-3750 is solved. Please test it on your side. Looking forward to your test feedback.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Wed Mar 23, 2022 10:41 pm

Hi Annika

Unfortunately, the new jar did not resolve the issue for us. Before it was failing on initialising the 'sprmlg' class but now it's the 'sprbgg' class ... might actually be the same class just the obfuscated name is now different.

java.lang.NoClassDefFoundError: Could not initialize class com.spire.xls.packages.sprbqg
at com.spire.xls.packages.sprrog.<init>(Unknown Source)
at com.spire.xls.packages.sprrog.<init>(Unknown Source)
at com.spire.xls.packages.sprvog.spr⑫┘(Unknown Source)
at com.spire.xls.packages.sprdaf.spr⑇⌮(Unknown Source)
at com.spire.xls.packages.spremj.spr↡╄(Unknown Source)
at com.spire.xls.packages.sprpmj.spr〄╂(Unknown Source)
at com.spire.xls.packages.sprpmj.spr〄╁(Unknown Source)
at com.spire.xls.packages.sprpmj.spr┞╂(Unknown Source)
at com.spire.xls.packages.sprpmj.spr⅞╂(Unknown Source)
at com.spire.xls.packages.sprpmj.spr●╁(Unknown Source)
at com.spire.xls.packages.sprpmj.spr┧╂(Unknown Source)
at com.spire.xls.packages.sprswp.spr┡┢(Unknown Source)
at com.spire.xls.packages.sprjsj.spr⌻╂(Unknown Source)
at com.spire.xls.packages.sprjsj.spr│≌(Unknown Source)
at com.spire.xls.core.spreadsheet.XlsWorkbook.spr│≌(Unknown Source)
at com.spire.xls.Workbook.spr⑀╆(Unknown Source)
at com.spire.xls.Workbook.saveToStream(Unknown Source)
at nz.co.dairyinsight.dairydata.report.ExcelReportProcessingService.formatWorkbookForDownload(ExcelReportProcessingService.java:461)

Are you able to give any details into what the suspected issue was and what fix was applied for it? This might help us on our side.

Also, if you could detail what Azure setup you are using and any specific configurations that may have been applied? e.g. system settings

Our setup:
Azure App Service running in Linux VM
Java 8
Tomcat 9
SpireXLS for Java v5.3.3

karenv_datacom
 
Posts: 15
Joined: Thu Apr 08, 2021 2:09 am

Thu Mar 24, 2022 10:21 am

Hello,

Thanks for your feedback.
I deployed the Java project directly to AzureWindows and found that it is no problem to use SpireXLS for Java v5.3.3, so I provide it to you. I'm still investigating and testing the environment you provided "Azure App Service running in Linux VM", and I'll let you know as soon as there is any progress. Thanks for your understanding.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Fri Mar 25, 2022 10:02 am

Hello,

Thanks for your patience.
I did an initial test in a Linux virtual machine on Azure and found no issues. I have attached my test project, please download it and test it on your side. If the problem persists after testing, please provide your Linux details, eg Ubuntu-20.04.3. Thanks in advance.
Also, please make sure that the JDK version on your Linux system is compatible with your local JDK.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Wed Mar 30, 2022 8:48 am

Hi Annika

I have run your jar file in our Azure Linux container and unfortunately an error is thrown. The 'result.pdf' is created but the file size is 0, and when I try to open the file Adobe gives an error of: "Adobe Acrobat Reader could not open 'result.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)."

See attached stacktraces. From what I can determine the only font installed on our Azure Linux vm is the DejaVu font family fonts. However, I'm not even sure these are accessible by our applications. This is why I specify a directory where I've put the font files using the setCustomFontFileDirectory() method.

I performed 2 tests using your test app:
1. report_template.xlsx containing text in DejaVu Sans font and the image - this resulted in an error "Cannot found font[DejaVu Sans] installed on the system." (see attached stack trace)
2. report_template.xlsx containing image only, NO text - this resulted in an error "Cannot found font[Calibri] installed on the system." (see attached stack trace)

Could you please modify your test application to use the setCustomFontFileDirectory() to retrieve the font used within the report template? I don't mind what font you use. We use Arial for our report templates.
Then hopefully we can get past the 'no font found' issue and see what happens.

In the meantime, I've done a few further elimination tests:

1. I ran your jar in a standalone Linux vm (not in Azure) and it ran successfully (with both text and image in the report_template.xlsx)
Linux 2.6.32-754.41.2.el6.x86_64 x86_64

2. I added a simple step in our application to read in the 'report_template.xlsx' file, and then immediately write it out to file as PDF.

com.spire.xls.Workbook spireXlsWorkbook = new com.spire.xls.Workbook();
spireXlsWorkbook.loadFromFile(testingTemplateFileName);
spireXlsWorkbook.saveToFile(testingReportFileName, FileFormat.PDF);

Results:
Running on my local windows machine with both text & image in template - runs successfully,
Running in our Azure Linux vm with both text & image in template - fails with error as previously given (Could not initialize class com.spire.xls.packages.sprbqg)
Running in our Azure Linux vm with text only - runs successfully
Running in our Azure Linux vm with image only - fails with same error (Could not initialize class com.spire.xls.packages.sprbqg)

When it fails a pdf file is created but with 0 size, and I get that same Adobe error when I try to open the file.

My Azure Linux details:
Linux 5.4.0-1063-azure x86_64
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.14.2
PRETTY_NAME="Alpine Linux v3.14"

Your help is much appreciated.

Karen
Attachments
Results.zip
(15.76 KiB) Downloaded 85 times

karenv_datacom
 
Posts: 15
Joined: Thu Apr 08, 2021 2:09 am

Wed Mar 30, 2022 9:59 am

Hello,

Thanks for your feedback.
I have modified the project code according to your needs, and attach the project here, please download and test it on your side.
In addition, you mentioned that the size of the result file is 0KB. After I tested it, I found that there is a time delay in the generation of the result file by "saveToStream", and an error will be reported when using Adobe to open it. But wait about 40 seconds, the size of the result file will be the actual size, then refresh the folder, and open the result file again without a problem.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Thu Mar 31, 2022 8:08 am

Thanks Annika

I ran your new project but unfortunately I get the error below. Both output.pdf and result.pdf files are created, but with size 0 and I can't open them. I did wait a couple of minutes (even longer) but the size remained 0. I have attached them.

java.lang.Error: Probable fatal error:No fonts found. (full stack trace attached)

I see in your code that you first save output.pdf using saveToFile() and then save result.pdf using saveToStream(). From the stack trace we can see it is the saveToFile() method that is causing the error to be thrown, however the result.pdf file still gets created too.

I tried running the project with a report_template.xlsx that only contains an image but get the same error with the same stack trace.

I don't see anything wrong with your font file code but it seems like it's not picking up the font directory.

Thanks again, Karen
Attachments
ExcelTest_Results.zip
(2.95 KiB) Downloaded 86 times

karenv_datacom
 
Posts: 15
Joined: Thu Apr 08, 2021 2:09 am

Return to Spire.XLS