Create, Save and Open Report Documents
- 4 minutes to read
The main ideas discussed in this topic are generation, storage, and distribution of report documents.
Calling the XtraReport.CreateDocument method fills data sources available in the report, supplies bound report controls with the obtained data, and starts building document pages. This method is called internally when loading a report in a Print Preview or exporting a document.
In the Visual Studio Report Designer, you can trigger document creation and preview the document by switching to the Preview tab below a report’s design surface.
Creating extensive documents may take a considerable amount of time. You can interrupt the page building process at any time by clicking Stop on the Print Preview’s status bar.
When using large data sources, you can reduce the load on your database server that filling the data source causes each time you switch to Preview by limiting the number of times the detail band is printed (see the XtraReportBase.ReportPrintOptions property description).
Save and Load Documents
You can save the created document to a file:
Report documents are compressed and stored in archive files with a PRNX extension by default. This file extension is used to filter data in the Save File and Load File dialogs displayed in a Print Preview.
The PRNX file is a zipped XML file that describes the document structure and embeds images. The report generates that document based on specified parameter values (if any) and culture settings.
DevExpress reports are backward compatible and do not need to be updated each time you upgrade your product version. However, forward compatibility is not guaranteed, which means that reports created in newer versions may not display correctly in older versions of components.
See Save and Open Report Documents to learn how to store documents in a file or stream and retrieve them from a Print Preview.
Consider storing report definitions along with published documents to be able to make changes to the document layout at a later time.
Make sure you take the necessary measures to protect your documents from unauthorized access. Consider using third-party tools to encrypt documents containing sensitive data or protect them using digital signatures.
See Reporting Security for more information.
A document contains a snapshot of dynamic data source content when it is created. Another document created from the same report can contain different information as a result of changes made to the report’s data source. Published documents often display a timestamp, user name, and information about parameter values assigned to the report to ensure the right context for published information and its validity.
Data presentation in published documents does not depend on the system’s culture and locale settings. A document’s culture-specific content does not change when viewing it on different machines.
A single exception to this is the XRPageInfo control that uses the current application thread’s culture settings to format its date-time values by default.
Use the PrintingSystemBase.Culture property to define a specific culture for rendering this control’s content to ensure consistency across various systems.
Culture-sensitive formatting applied to a report’s data may change when exporting to Excel if the report’s XlExportOptionsBase.TextExportMode property is set to TextExportMode.Value, which makes the resulting Excel document use the system formatting of the client machine on which export has been performed.
Fonts used in a document for rendering text are automatically replaced with the system’s default equivalents if they are missing on a client machine.
See Globalize and Localize Reports to learn more about culture-specific report settings.
Document pages are not available for a report until its document is created. You can use report events to adjust the layout of a report’s content in a published document.
When publishing a document, the Printing System transforms each report control into a graphical primitive (brick) corresponding to the control’s type. A brick renders a control’s content and defines its size and location on a document’s page.
In most cases, you do not need to access and manipulate individual bricks because you can manipulate elements in a report instead. See Printing-Exporting for more information about the low-level API the printing library uses to create documents.