The requested page is not available for the requested platform. You are viewing the content for Default platform.

XtraReport.CreateDocument() Method

Creates a document from the XtraReport object, so it can be displayed or printed.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v18.2.dll

Declaration

public void CreateDocument()
Public Sub CreateDocument

Remarks

Calling the CreateDocument method creates a report document that is ready to preview, print and export.

The created document can then be accessed via the PrintingSystemBase.Document property of a report's XtraReport.PrintingSystem, and the page collection is available via the XtraReport.Pages property. For a code example, refer to Merging Reports.

Note

Once the document creation has started, it will run until the resulting document is complete and cannot be interrupted or canceled in the process.

To be able to access document pages progressively as they are created, as well as interrupt or cancel the document creation, call the CreateDocument method overload with the buildForInstantPreview parameter set to true.

The CreateDocument method is called internally from the following methods (i.e., it is not required to call CreateDocument before calling one of the following methods).

Calling the CreateDocument method is not required after assigning a report to the ASPxDocumentViewer or ASPxWebDocumentViewer control.

An explicit call to the CreateDocument method is required only to refresh the document and after making changes to the report, prior to showing its preview, printing and/or exporting it.

If a report contains parameters and the XtraReport.RequestParameters property is set to true, calling the CreateDocument method will not invoke the Parameters form that enables end-users to enter parameter values, unless DevExpress.XtraPrinting.v18.2.dll is added to the project's reference list and the following code is executed.

using DevExpress.XtraReports.UI;
// ...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();
    ReportPrintTool tool = new ReportPrintTool(report);
    report.CreateDocument();
}

After this code assigns a ReportPrintTool to the report, calling the CreateDocument method invokes the dialog requesting the report parameters' values.

ReportParameters3

Note

An attempt to call the CreateDocument method for a report that does not contain the DetailBand raises an exception (in particular, when creating a report in code). Add this band to the report even if you do not need to display information in it.

Examples

This example illustrates the use of the XtraReport.CreateDocument method. The report's Print Preview is shown by using ReportPrintTool.

In this example, an XRLabel object contained in the XtraReport1 class has its Modifiers property set to public.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
// ...

private void button1_Click(object sender, EventArgs e) {
    // Create a report and assign to a Print Tool.
    XtraReport1 report = new XtraReport1();
    ReportPrintTool printTool = new ReportPrintTool(report);

    // Show the report's preview for the first time.
    printTool.ShowPreviewDialog();

    // Change the report's contents.
    ((XtraReport1)printTool.Report).xrLabel1.BackColor = Color.Blue;

    // Create the report's document.
    printTool.Report.CreateDocument();

    // Show the report's preview for the second time.
    printTool.ShowPreviewDialog();
}
See Also