Skip to content

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

  1. The caller sets ReportPath to the target SSRS report.
  2. The caller optionally sets Format (defaults to PDF, mapping to extension pdf) or ImageFormat (defaults to JPEG) through the respective property setters, which translate the enum value into the internal m_Format/m_Extension or m_ImageFormat strings used by the render call.
  3. The caller optionally queues report parameters with one or more AddParameter(name, value) calls, or clears them with ClearParameters().
  4. PreviewDocument assigns System.Net.CredentialCache.DefaultCredentials to the generated SSRS proxy's Credentials property.
  5. PreviewDocument calls m_RS.LoadReport2(ReportPath, HistoryID) to load the target report.
  6. HistoryID is deliberately left uninitialized rather than assigned an empty string, because initializing it causes the call to fail with an invalid SnapshotId error.*
  7. If the parameter collection has entries, PreviewDocument allocates a ParameterValue array sized to the collection, calls BuildParameters to copy each name/value pair into it, and submits the array through m_RS.SetExecutionParameters.
  8. PreviewDocument calls m_RS.Render2 with the configured format, extension, and PageCountMode.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

  • DistributeDocument on clsRSPrint always throws NotImplementedException (BR-006); consumers needing distribution must use the xPression-based Distribute document (synchronous or asynchronous) operation instead.
  • PreviewDocument does not catch exceptions from LoadReport2, SetExecutionParameters, or Render2; any SOAP fault propagates directly to the caller.*
  • HistoryID is passed uninitialized to LoadReport2 by design (per the inline source comment); explicitly initializing it is documented in source as causing the call to fail.

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