Skip to Content

How to export a individual Deski report from a Deski document containing multiple reports using the Report Engine .NET SDK

The code for working with Webi and Deski documents is essentially identical and alot of the same code is used when working with both objects, this includes things such as exporting.

One of the areas where they diverge is when you try and export an individual report from a document that contains more than one report.

For example, you have a webi document that contains 3 webi reports.  The code to export the 2nd report to pdf is as follows:

********************************************

IDocumentInstance boIDocumentInstance = boIReportEngine.OpenDocument(boInfoObjects[1].ID);
boIDocumentInstance.Refresh();

//Caste it to a IReport object and set the PaginationMode, this is mandatory
IReport rep = boIDocumentInstance.Reports[1];

//Export and stream to pdf
IBinaryView boIBinaryView = (IBinaryView)rep.GetView(OutputFormatType.Pdf);

Response.ContentType = “application/pdf”;
Response.AddHeader(“Content-disposition”, “inline;filename=document.pdf”);
boIBinaryView.WriteContent(Response.OutputStream);

********************************************

When trying to use this same code with a deski document you will get the error:

“The requested supported view is invalid.  Parameter: PDF”  which seems to make little sense since it says right there in the error that the view that is being requested is supported, but not valid…Ok..

So to accomplish the same with a deski document you have to manipulate the reports paginationmode.  By default the mode is Page which will not allow the export.  This needs to be changed to Listing to allow the export.

The code is just:

********************************************

IDocumentInstance boIDocumentInstance = boIReportEngine.OpenDocument(boInfoObjects[1].ID);
boIDocumentInstance.Refresh();

//Caste it to a IReport object and set the PaginationMode, this is mandatory
IReport rep = boIDocumentInstance.Reports[1];

//Added for Deski documents
rep.PaginationMode = PaginationMode.Listing;

//Export and stream to pdf
IBinaryView boIBinaryView = (IBinaryView)rep.GetView(OutputFormatType.Pdf);

Response.ContentType = “application/pdf”;
Response.AddHeader(“Content-disposition”, “inline;filename=document.pdf”);
boIBinaryView.WriteContent(Response.OutputStream);

********************************************

I hope this helps as I did not find anything documented on this and this simple line of code can save alot of headaches 🙂

Be the first to leave a comment
You must be Logged on to comment or reply to a post.