I saw there is a property to exclude the hidden sheets here and here.
But, when I tried to see it in the code, I didn't find it.
I'm using version 2019.3.1021.
Is it not available on my version?
If yes, is there any workaround?
Thank you.
1 Answer, 1 is accepted
1
Accepted
Svilen
Telerik team
answered on 14 Mar 2022, 12:59 PM
Hi, Yudith,
Svilen here, I will be glad to help out with this question.
As noted in our PdfFormatProvider Settings article, the property responsible for this functionality is PdfExportSettings.IncludeHiddenSheets, which is set to false by default. We've added this property as a response to the request to skip hidden sheets, posted in this public feedback item - SpreadProcessing: Hidden sheets should not be exported to PDF. It is available for versions post 2021.3.1025.
Still, if you are unable to update, a workaround for this would be to create a copy of the workbook you wish to export, iterate through it and delete all hidden sheets before exporting. Here is a sample snippet code on how to do this:
Workbook exportCopy = workbook; //Create a copy solely for exporting. The original is not affected.foreach (var sheet in exportCopy.Worksheets)
{
if (sheet.Visibility == SheetVisibility.Hidden)
exportCopy.Worksheets.Remove(sheet);
}
using (Stream output = new FileStream("PDF.pdf", FileMode.Create))
{
pdfProvider.Export(exportCopy, output);
}
Please let me know if this helps.
Regards,
Svilen
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.