We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ConvertToPdf an xls document with a pivot table fail

Hello, i face an exception with the pdf convertor, and no way to get rid of it.

Find below the code, simply loading the file and attempting to convert it and enclosed the sample file.

System.ArgumentNullException: 'Value cannot be null.
Parameter name: PivotTable cannot be created for table with Named Range'

            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                IApplication application = excelEngine.Excel;
                FileStream excelStream = new FileStream(@"master.xlsx", FileMode.Open, FileAccess.Read);
                IWorkbook workbook = application.Workbooks.Open(excelStream);               
              
                XlsIORenderer renderer = new XlsIORenderer();
                PdfDocument pdfDocument = renderer.ConvertToPDF(workbook); // fail here
                Stream stream = new FileStream(@"output.pdf", FileMode.Create, FileAccess.ReadWrite);
                pdfDocument.Save(stream);

                excelStream.Dispose();
                stream.Dispose();
            }

Thanks for your help.

Reproduced using nugetversion 16.4.0.54 using a dot net core 2.2 console app.

Attachment: master_746288b8.zip

4 Replies

DB Dilli Babu Nandha Gopal Syncfusion Team March 21, 2019 09:43 AM UTC

Hi Jean, 

Thank you for contacting Syncfusion support. 

We can reproduce the reported issue with “Exception occurs while converting a Workbook to PDF” and suspect it as a defect. We are analyzing on this and will update the further details by 25 March 2019. 

Regards, 
Dilli babu. 



DB Dilli Babu Nandha Gopal Syncfusion Team March 25, 2019 04:01 PM UTC

Hi Jean, 
 
On the analysis, we found that the pivot table in the Excel document is created using external range. Currently, XlsIO does not have support for creating pivot table from external source.  However, we may able to skip the exception while conversion to show only the data. The pivot table styles will not be preserved in the output PDF document.  We have logged a defect report for this and we will skip the exception issue in our future release 2019 Volume 1 Service Pack 1 which will be rolled out by the end of April 2019. 
 
You can track the creation of pivot table from external range feature using feedback report which is available in the following link. 

Regards, 
Dilli babu. 



JE JeanR March 26, 2019 08:54 AM UTC

Thanks, so a different worksheet in the same document is considered as an external source ?
I was aware about the fact that external (odbc, other document on the filesystem etc..) was not supported, however a simple table/range in the same file should be supported.
Looking forward for a fix :)



DB Dilli Babu Nandha Gopal Syncfusion Team March 27, 2019 01:16 PM UTC

Hi Jean, 
 
In the given input document, the data source for the pivot table is set as external named range. But, the name of the input document and the external workbook name are same. So, Microsoft Excel refers the data from the same input document. However, we have considered this scenario as an issue from our side and it will be fixed in our future release 2019 Volume 1 SP1. After this fix, the output document will contain styles for the pivot table. 

Regards, 
Dilli babu. 


Loader.
Live Chat Icon For mobile
Up arrow icon