This example illustrates how to preview a DevExpress Report document (*.PRNX) using the WPF Document Viewer.
The Document Preview Control supports the following document sources:
- DevExpress Reports.
- DevExpress Report Documents: Store Report Documents. It can be:
- A stream containing report document data: Saving Documents to a Stream;
- A string containing a path to a PRNX file which stores report document data: Saving Documents to a File.
- An object implementing the ILink interface: WPF Controls | Printing Links.
To preview a document:
- Generate a document from a report by calling the
PrintingSystemBase.SaveDocument
method:
private void button1_Click(object sender, System.EventArgs e) {
// Create a report instance.
XtraReport1 report = new XtraReport1();
// Generate a complete report document.
report.CreateDocument();
// Save the document to a file.
report.PrintingSystem.SaveDocument(@"...\Invoice.prnx");
}
- Assign a path to the resulting document or a stream with document data to the
DocumentViewerControl.DocumentSource
property at runtime:
documentPreview.DocumentSource = @"...\Invoice.prnx";