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.

Thu Sep 13, 2018 7:24 am

I am currently evaluating the paid version of Spire.XLS.

Part of our process is to convert several sheets of our created workbook to pdf files. For testing purposes I created a workbook with 10 sheets (all of them have the same content). Sequential conversion is working fine, it's creating the 10 pdf files with one page each as expected. As converting can be rather slow (though still 4.33 times faster than excel interop for my 10 sheets) I tried parallel execution of the conversion. This did not work at all.

Sometimes some of the tasks are null (with the exception "a workbook must contain at least one visible worksheet"), sometimes the tasks run successfully but all returned pdf files contain all 10 sheets, sometimes one of the tasks fails with "'The process cannot access the file '...\ConversionResult8.pdf' because it is being used by another process."

Am I doing something wrong or is parallel conversion not supported?
I know that it may not be worth to run the conversion in parallel but I cannot compare it to sequential execution if it doesn't run successfully.

Here's the code in question:
Code: Select all
var workbook = new Spire.Xls.Workbook();
            workbook.LoadFromFile(@"..\..\test.xlsx", ExcelVersion.Version2016);
            var conversionTasks = new Task[workbook.Worksheets.Count];
            for (var i = 1; i <= workbook.Worksheets.Count; i++)
            {
                conversionTasks[i - 1] = Task.Factory.StartNew(() => workbook.Worksheets[i].SaveToPdf(@"..\..\ConversionResult" + i + @".pdf"));
            }
            await Task.WhenAll(conversionTasks);

AdrianGiegerich
 
Posts: 2
Joined: Thu Sep 06, 2018 11:08 am

Thu Sep 13, 2018 9:06 am

Dear Adrian,

Thanks for your inquiry.
Based on our internal conversion mechanism, converting sheet to Pdf in parallel way is not supported at present. If it can be fixed in the future, we will let you know. Sorry for the inconvenience caused.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Thu Sep 13, 2018 9:18 am

Alright, thank you for the quick answer.

AdrianGiegerich
 
Posts: 2
Joined: Thu Sep 06, 2018 11:08 am

Thu Sep 13, 2018 9:23 am

Hi,

If you have other questions related to our product, just feel free to write back.
Wish you all the best!

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.XLS