A workbook must contain at least a visible worksheet

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

When I process xlsx document who has 2-first sheets hidden (from 4) I receive exception:

exceptions.ClassName: GroupDocs.Viewer.Exceptions.GroupDocsViewerException
exceptions.Message: A workbook must contain at least a visible worksheet
ExceptionDetail.TargetSite: Void (Int32[], GroupDocs.Viewer.Interfaces.IFileStreamFactory)
exceptions.StackTraceString:
at e.e(Int32[] , IFileStreamFactory )
   at .(Int32[] , PdfViewOptions ,  )
   at .e(Func`3 , ViewOptions , CancellationToken , Int32[] )
   at .e(Func`3 , ViewOptions , CancellationToken )
   at GroupDocs.Viewer.Viewer.View(ViewOptions options, CancellationToken cancellationToken)

It’s look like an issue on groupdocs viewer.
Could you investigate it?

I Use .NET 6 and GroupDocs.Viewer 23.1.0

Sample:
sample.7z (7.4 KB)

@D04486411

I can’t reproduce the attached file and this sample-app.zip (9.1 KB). Can you please share the code you are running or update the attached app?

@vladimir.litvinchik

Try set option: viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet();
in RenderAsPdf method. Then you should reproduce this.

Moreover when xlsx is build like that:
Sheet1 - visible
Sheet2 - hidden
Sheet3 - hidden
Sheet4 - visible

Then pdf result has only Sheet1 insteadof Sheet1 and Sheet4. Sheet4 is lost.

@D04486411

Thanks, now I can reproduce the issue. We’ll take a look into the code and share the updates.

@D04486411

We have successfully resolved the issue at hand. The fix has been implemented and is scheduled to be included in the upcoming public version, which is expected to be released by the end of this month. We will notify you promptly as soon as the new version becomes available.

@vladimir.litvinchik

Did this fix will be work for xlsx, xls and also ods files?

@D04486411

Yes, this fix is for all spreadsheets.

1 Like

@D04486411

This issue has been fixed in GroupDocs.Viewer for .NET 23.6. The version is available at

Have a nice day!