Generate Configurable Business Document as Byte Array

In this article, we will show you how to generate Customer account statement, which is a Configurable business document, as a byte array in both original (Excel/Word) and PDF format.

Configurable business documents sit on top of SSRS and cannot be generated outside the SSRS report execution pipeline, because the SSRS framework is responsible for preparing the data and cleaning them up, after report run is completed. Actually, this is true only for pre-processed SSRS reports, where belong all main reports such as Sales invoice and Purchase order. For regular SSRS reports, including those which are query-based, e.g. Container contents report, there is no such limitation.

Printing a Configurable business document to memory can be useful, for example, if you want to deliver both PDF and Excel output formats to your customers. Let’s say that you are using Docentric to produce nicely designed PDF documents when printing the Customer account statement report. But some customers demand to get the same data in an Excel document, to be able to process it as they used to.

For that reason, we created a handy helper class, DocERFormatGeneratorCBD, which can be invoked from SSRS or Docentric pipeline, to generate the currently executing SSRS report as a Configurable business document to memory. The only parameter you have to provide is the exact ER Format mapping GUID. In this example, we will generate the Excel document as a byte array for the given ER Format mapping of the executing Customer account statement report. The generation will take place in the Docentric DSP class for Customer account statement, but you can also do it anywhere from SSRS pipeline, after data preparation is completed and before the data clean-up is done.

In the example below, we extended the Docentric DSP class for Customer statement report (DocCustAccountStatementExtReportDSP) and invoked the CBD generator class (DocERFormatGeneratorCBD) in the extended overrideReportRunSettings() method.

The result of the code above are the outgoing emails with the attached two documents:

  • PDF document generated by Docentric (or SSRS),
  • Excel document generated by Electronic Reporting.

If you want to get the PDF output from the generated Excel document, you can! Just use the getPdfDocumentContentMemoryStream() method on the generator class instead.

This method invokes Microsoft Office Conversion Service, which is used for converting Configurable business documents in Word and Excel to PDF.

The DocERFormatGeneratorCBD class is part of Docentric Free Edition, which you can download and use completely for free.

If you need to generate any Electronic reporting document to memory, check out our previous article!
Generate Electronic Reporting Format as Byte Array >>

 

Leave a Reply

Your email address will not be published.

*

Docentric respects your privacy. Learn how your comment data is processed >>

Docentric respects your privacy. Learn how your comment data is processed >>