A component that manages caching logic and acts as a mediator between a report and a Document Viewer.
[ToolboxBitmap(typeof(ResFinder), "Bitmaps256.CachedReportSource.bmp")] public class CachedReportSource : CachedReportSourceBase, IReport, IDocumentSource, ILink, IComponent, IDisposable, IServiceProvider, IExtensionsProvider
<ToolboxBitmap(GetType(ResFinder), "Bitmaps256.CachedReportSource.bmp")> Public Class CachedReportSource Inherits CachedReportSourceBase Implements IReport, IDocumentSource, ILink, IComponent, IDisposable, IServiceProvider, IExtensionsProvider
Use the CachedReportSource component to avoid memory consumption-related issues when you display, print or export large documents. This component generates a report document and caches each generated page in the specified storage. The following document storages are available:
Allows you to store a document in memory in a compact way.
Allows you to store a document as a set of files in a specified directory.
Allows you to a store a document in a specified database.
You can also inherit from the DocumentStorage class to implement a custom document storage.
The following code demonstrates how to create a CachedReportSource instance.
using DevExpress.XtraPrinting.Caching; //... var storage = new MemoryDocumentStorage(); var report = new MyReport(); var cachedReportSource = new CachedReportSource(report, storage);
When you dispose of the CachedReportSource component, the storage it uses is disposed of as well. The storage content is cleared if DocumentStorage.ClearOnDispose is enabled.
The disposal can take some time if it is invoked while the document is generated, because the CachedReportSourceBase.StopPageBuilding method waits until the currently generated page is ready.
Display Large Reports
To display a report in a Document Viewer, assign the CachedReportSource component to the DocumentViewer.DocumentSource (WinForms) / DocumentViewerControl.DocumentSource (WFP) property. Refer to the Quick Start (WinForms) / Quick Start (WPF) section for details.
The document created by the CachedReportSource component is regenerated each time users edit it in the Document Viewer (when they change margins, paper format, or watermark).
Merge Large Reports
When you merge a large document with another document, use the CachedReportSource component's CachedReportSourceBase.CreateDocument method beforehand to generate the document. Then, use the XtraReport.ModifyDocument or CachedReportSourceBase.ModifyDocument method to manipulate the generated document's page set.
Print and Export Large Reports
To print or export a large document in code without displaying it in a Document View, use the CachedReportSource component's CachedReportSourceBase.CreateDocument method to generate the document. Then access the CachedReportSource.PrintingSystem property to utilize the document's Printing System and its printing and exporting methods.
Use Caching in Web Reporting Applications
- The CachedReportSource component cannot be associated with reports that include a PrintableComponentContainer.
- The Page.AddBrick method does not work if you use the CachedReportSource/CachedReportSourceWeb component to create report documents.
- When using the CachedReportSource component to generate a report document, the XRControl.PrintOnPage event is raised each time a page with the current control is created. In this connection, the total number of pages is unknown at the moment the event fires and you cannot use the PrintOnPageEventArgs.PageCount property in the event handler.
- The XtraReport.RollPaper mode is not supported.
- When creating a report document, the CachedReportSource component generates information required for a single-file export. This increases memory consumption. Disable the CachedReportSourceBase.AllowSingleFileExport option if you are not going to export the generated document in single-file mode.