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 Jan 04, 2022 9:44 pm

Hello,

I have a problem in which I am copying multiple worksheets from multiple xlsx files into one workbook and then saving that as a PDF file. This is working great for regular worksheets with tables of data however the worksheets that contain charts are not rendering in the PDF file. They are just showing up as blank pages in the pdf file. Is this a limitation of the product?

Regards,
Jerry

jerrykelso
 
Posts: 3
Joined: Thu Dec 30, 2021 3:04 pm

Wed Jan 05, 2022 7:00 am

Hello,

Thanks for your inquiry!
I simulated an excel file and tested you case with our latest Spire.XLS Pack(Hotfix) Version:11.12.2, but I did not reproduce your problem. To investigate further, please provide the following more information, thanks in advance.
1. Your excel file, you can upload it here or send it to us via email (support@e-iceblue.com).
2. Your system information (E.g. Win7, 64 bit) and region setting (E.g. China, Chinese).
3. The target platform of your project(E.g. .NET framework 7.0).

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Wed Jan 05, 2022 3:23 pm

Hello,

I have emailed the source files I am using as well as the output I am getting back. I am using windows 10 running IIS under .net framework 4.0.

In my code I create a new workbook, copy selected sheets (including the charts) from each workbook and save the result as both xlsx and pdf. As you will see from my emailed output, the charts in the PDF are missing. (In addition it looks like the numeric formatting in the charts gets lost in the xlsx version.)

Regards,
Jerry Kelso

jerrykelso
 
Posts: 3
Joined: Thu Dec 30, 2021 3:04 pm

Thu Jan 06, 2022 9:31 am

Hello,

Thank you for sharing your files.
When opening your “Source 2.xlsx” in MS Excel, I noticed that it has extra links can not be updated, as shown in the attached screenshot. For this kind of file, our Spire.XLS also can not update the related data when copying its worksheets. This caused some data missed. If I only copy the worksheets of “Source 1.xls” and add them in “Source 2.xlsx” like the following code. The chart data will remain. You can try this on your side. If there is still any issue, just feel free to write back.
Code: Select all
Workbook original = new Workbook();
 original.LoadFromFile(@"Source 1.xls");
 Workbook target = new Workbook();
 target.LoadFromFile(@"Source 2.xlsx");
     foreach (Worksheet sheet in original.Worksheets)
     {
         target.Worksheets.AddCopy(sheet);
     }
 target.SaveToFile(@"output.xlsx", ExcelVersion.Version2013);
 target.ConverterSetting.SheetFitToPage = true;
 target.SaveToFile(@"output.pdf", Spire.Xls.FileFormat.PDF);


Sincerely,
William
E-iceblue support team
Attachments
extraData.png
extraData.png (49.3 KiB) Viewed 487 times
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Fri Jan 07, 2022 2:48 pm

Hello William,

I suspected that the problem was due to the updating of the data used by the charts. Thanks for confirming this. Unfortunately I can't use the procedure you describe in my application as potentially both source files may contain these charts. However I did find a workaround that works perfectly for me. When I know that the worksheet contains charts, instead of copying the sheet to the new workbook, I save the sheet as an image and then put that image into a new blank worksheet. For the purposes of saving the whole thing as a pdf, this is fine and the quality when printed still looks great. Thanks for you help with this.


Regard,
Jerry

jerrykelso
 
Posts: 3
Joined: Thu Dec 30, 2021 3:04 pm

Mon Jan 10, 2022 9:33 am

Hello,

Glad to hear that! If you encounter any issues related to our products in the future, just feel free to contact us.
Wish you all the best!

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.XLS