A component that manages caching logic and acts like 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
When displaying/printing/exporting huge documents containing thousands of pages, use the CachedReportSource component to avoid memory consumption-related issues. This component generates a report document caching 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 implement a custom document storage by inheriting from the DocumentStorage class.
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 disposing of the CachedReportSource component, the storage it uses is disposed of as well. The storage's content is cleared if DocumentStorage.ClearOnDispose is enabled.
The disposing operation can take some time if it is invoked during document generation, because the CachedReportSourceBase.StopPageBuilding method waits until the currently generated page is ready.
Display Large Reports
To use the CachedReportSource component for displaying a report in a Document Viewer, assign it to the DocumentViewer.DocumentSource (WinForms) / DocumentViewerControl.DocumentSource (WFP) property. For details, refer to the Quick Start (WinForms) / Quick Start (WPF) section.
The document created by a CachedReportSource component is regenerated each time an end user edits it in a Document Viewer (when changing margins, a paper format or watermark).
Merge Large Reports
When merging a large document with another document, use the CachedReportSource component's CachedReportSourceBase.CreateDocument method to generate the document and the CachedReportSourceBase.ModifyDocument method to manipulate with the page set of the generated document.
Print and Export Large Reports
To print or export a large document in code without displaying it in a Document View, generate the document using the CachedReportSource component's CachedReportSourceBase.CreateDocument method and access the document's Printing System and its printing and exporting methods using the CachedReportSourceBase.PrintingSystem property.
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.