Preview SSRS report¶
clsRSPrint.PreviewDocument renders an SSRS report through the SharepointReporting.ReportExecutionService SOAP endpoint. It is a separate, standalone code path from the xPression preview/print/distribute workflow in clsPrint; it does not share state or transport with xPression at all. clsRSPrint supports preview and render only — its DistributeDocument method always throws.
| Field | Value |
|---|---|
| Operation ID | OP-PRT-08 |
| Trigger | Caller sets ReportPath, optionally Format/ImageFormat, optionally queues parameters via AddParameter, then invokes PreviewDocument() |
| Inputs | Report path; output format (CSV, Excel, HTML, Image, PDF, Word, XML); image format when applicable; a name/value parameter collection |
| Outputs | Rendered report byte array in the selected format |
| Primary components | clsRSPrint.PreviewDocument, clsRSPrint.BuildParameters, clsRSPrint.AddParameter |
| Entry point | Services\SAIF.Services.Printing\clsRSPrint.vb |
Steps¶
- The caller sets
ReportPathto the target SSRS report. - The caller optionally sets
Format(defaults toPDF, mapping to extensionpdf) orImageFormat(defaults toJPEG) through the respective property setters, which translate the enum value into the internalm_Format/m_Extensionorm_ImageFormatstrings used by the render call. - The caller optionally queues report parameters with one or more
AddParameter(name, value)calls, or clears them withClearParameters(). PreviewDocumentassignsSystem.Net.CredentialCache.DefaultCredentialsto the generated SSRS proxy'sCredentialsproperty.PreviewDocumentcallsm_RS.LoadReport2(ReportPath, HistoryID)to load the target report.HistoryIDis deliberately left uninitialized rather than assigned an empty string, because initializing it causes the call to fail with an invalidSnapshotIderror.*- If the parameter collection has entries,
PreviewDocumentallocates aParameterValuearray sized to the collection, callsBuildParametersto copy each name/value pair into it, and submits the array throughm_RS.SetExecutionParameters. PreviewDocumentcallsm_RS.Render2with the configured format, extension, andPageCountMode.Actual, and returns the resulting byte array.
Process flow¶
The following diagram visualizes the SSRS preview sequence.
flowchart TD
Start([Caller sets ReportPath, Format,<br>optional parameters]) --> Cred[Assign default credentials]
Cred --> Load[Call LoadReport2]
Load --> HasParams{Parameters queued?}
HasParams -->|Yes| Build[BuildParameters and<br>SetExecutionParameters]
HasParams -->|No| Render
Build --> Render[Call Render2]
Render --> End([Return rendered bytes])
Failure and edge-case behavior¶
DistributeDocumentonclsRSPrintalways throwsNotImplementedException(BR-006); consumers needing distribution must use the xPression-based Distribute document (synchronous or asynchronous) operation instead.PreviewDocumentdoes not catch exceptions fromLoadReport2,SetExecutionParameters, orRender2; any SOAP fault propagates directly to the caller.*HistoryIDis passed uninitialized toLoadReport2by design (per the inline source comment); explicitly initializing it is documented in source as causing the call to fail.
Related documentation¶
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
Services\SAIF.Services.Printing\clsRSPrint.vb