Information about spliting sheets into pages

Hello,

I use viewer to view spreadsheet as pdf.
viewer.View(pdfViewOptions) with spreadsheetOptions

I use options SpreadsheetOptions.ForSplitSheetIntoPages
How can I get information how the sheet is divided into pages?
I want to know how many pages in pdf, specific sheet takes.

I Use .NET 6 and GroupDocs.Viewer 22.11.0

Best regards

@D04486411

Unfortunately, we do not have GetViewInfo method that can be used when exporting to PDF. But you can still use PngViewInfoOptions to retrieve the list of pages that are going to be rendered. The following code is rather a workaround that is based on the fact that a worksheet name should be unique.

 using(Viewer viewer = new Viewer("spreadsheet.xlsx"))
 {
     ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForPngView();
     viewInfoOptions.SpreadsheetOptions = SpreadsheetOptions.ForSplitSheetIntoPages(50);
 
     ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions);
 
     viewInfo.Pages
         .GroupBy(p => p.Name)
         .Select(g => new { Worksheet = g.Key, CountPages = g.Count() })
         .ToList()
         .ForEach(r => Console.WriteLine($"{r.Worksheet} : {r.CountPages}"));
 }

Sample console output:

Sheet1 : 3
Sheet2 : 5
1 Like