Welcome to the WinForms feedback portal. We’re happy you’re here! If you have feedback on how to improve the WinForms, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
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
Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyConditionlFormats Or
Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyColumnHeight Or
Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyDataValidations Or
Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyMerges Or
Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyNames Or
Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyOptions Or
Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyPalette Or
Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyPivotTables Or
Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyRowHeight Or
Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyShapes)
'These other flags are not handled very well:
'Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyAutoFilters
'Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyPageSetup
'Syncfusion.XlsIO.ExcelWorksheetCopyFlags.CopyTables
Next
Using con As New Syncfusion.ExcelToPdfConverter.ExcelToPdfConverter(wb2)
Dim pdfDoc As New Syncfusion.Pdf.PdfDocument = con.Convert()
pdfDoc.Save(pStream)
End Using