Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Mar 21, 2019 7:02 am

HI,

I want to output two sheets in an Excel workbook, and merge into single pdf, I found that when I call Worksheet.Dispose(), the result is incorrect (different pages, different sheet), , is there any guideline for this problem?

Another problem is equation in cell F1 didn't render in output pdf file, whether calling worksheet.Dispose() or not.

Thanks in advance.

Code: Select all
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("test.xlsx", ExcelVersion.Version2016);

            string[] sheets = { "001", "002" };
            List<MemoryStream> pdfList = new List<MemoryStream>();
            for (int i = 0; i < sheets.Length; i++)
            {
                Worksheet ws = workbook.Worksheets[sheets[i]];
                if (ws == null) continue;

                MemoryStream stream = new MemoryStream();
                ws.SaveToPdfStream(stream);

                pdfList.Add(stream);

                // *** This line produces incorrect pdf file
                //ws.Dispose();
            }

            string outputFile = "result.pdf";
            PdfDocumentBase pdf = PdfDocument.MergeFiles(pdfList.ToArray());
            pdf.Save(outputFile);
            System.Diagnostics.Process.Start(outputFile);

            workbook.Dispose();

abc_123_abc
 
Posts: 5
Joined: Wed Mar 20, 2019 1:41 am

Thu Mar 21, 2019 7:05 am

Hi,

This is excel file, sorry I forgot to uplaod it.

test.xls.zip

abc_123_abc
 
Posts: 5
Joined: Wed Mar 20, 2019 1:41 am

Thu Mar 21, 2019 9:23 am

Hello,

Thank you for contacting us and below are my answers to your questions.
1. About Worksheet.Dispose(), please kindly note that you can not dispose a worksheet when you were still using an excel workbook, because there are some relationships between in these sheets.
2. Regarding the equation in cell F1, sorry our Spire.XLS doesn't support converting this kind of format equation to PDF at present, we will consider adding it as a new feature into our upgrade list. If it can be achieved in the future, we will let you know.

Sincerely,
Lisa
E-iceblue support team
Last edited by Lisa.Li on Sun Mar 24, 2019 8:54 am, edited 1 time in total.
User avatar

Lisa.Li
 
Posts: 1534
Joined: Wed Apr 25, 2018 3:20 am

Thu Mar 21, 2019 1:50 pm

Hello Lisa,

Thanks for your quick response. It really helps.

abc_123_abc
 
Posts: 5
Joined: Wed Mar 20, 2019 1:41 am

Fri Mar 22, 2019 1:22 am

Hello,

Glad to hear that! If we can help you with anything else, please feel free to contact.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1534
Joined: Wed Apr 25, 2018 3:20 am

Fri Nov 06, 2020 10:34 am

Hello,

Glad to inform that we just released Spire.XLS Pack(Hotfix) Version:10.11.2 which supports mathematical formulas when converting Excel to PDF. Please download it from the following links to test.
Website link: https://www.e-iceblue.com/Download/download-excel-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.XLS/

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1534
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF

cron