I have an excel file loaded in by an end user that I want to convert to a pdf. However, the user created a data table from columns. The infinite-rowed table causes the xlsIO ExcelToPdfConverter to take an incredibly long time to create a pdf which would probably be thousands of pages long. Similarly when the file uses the native excel print preview handling, it previews as thousands of pages. See the attached file. It is only 11kb, but would generate a pdf thousands of pages long even though it has data on only 2-3 pages.
In excel, I can right click any cell in the table, and in the menu select Table > Convert to Range. If I save the excel file that way before generating a pdf through code, the resulting pdf is what I want.
I would like to do that converting from a table to a range in code before converting to a pdf.
For a workaround, I found I can copy the used data into a new sheet as long as I use ExcelWorksheetCopyFlags to ensure that CopyTables and a few others are not selected:
Dim wb2 As Syncfusion.XlsIO.IWorkbook = mExcelEngine.Excel.Workbooks.Create()
wb2.Version = mWorkBook.Version
For Each ws As Syncfusion.XlsIO.IWorksheet In mWorkBook.Worksheets
wb2.Worksheets.AddCopy(ws, Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyCells Or
'These other flags are not handled very well:
Using con As New Syncfusion.ExcelToPdfConverter.ExcelToPdfConverter(wb2)
Dim pdfDoc As New Syncfusion.Pdf.PdfDocument = con.Convert()