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

XtraReport.ExportToImage(String, ImageExportOptions) Method

Exports a report to the specified file path in Image format using the specified Image-specific options.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

public void ExportToImage(
    string path,
    ImageExportOptions options
)
Public Sub ExportToImage(
    path As String,
    options As ImageExportOptions
)

Parameters

Name Type Description
path String

A String which specifies the file name (including the full path) for the created Image file.

options ImageExportOptions

A ImageExportOptions object which specifies the Image export options to be applied when a report is exported.

Remarks

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

Use this method to export a report to Image file using the specified Image export options (like ImageExportOptions.Format, etc.) Note that in this instance the current report export options, which are represented by the ImageExportOptions object returned by the ExportOptions.Image property of a report's XtraReport.ExportOptions, are ignored.

If, instead, you want to use the current export options of a report, you should call the overloaded XtraReport.ExportToImage method without the options parameter.

Note

This method overwrites any files present at the specified path that have the same file name without any warnings.

Note

For more information on using the ExportToImage method, and limitations on export to Image, please refer to the Export to Image document.

Examples

The following example demonstrates how to export a report to image. To do this, the XtraReport.ExportToImage method should be used. It also demonstrates what specific ImageExportOptions may be used when a report is exported to image.

For this example to work, you first need to add a new report (named XtraReport1) to your project, drop some report controls onto it, and then execute the code below (for instance, in the Button.Click event handler of any button on a form). Note also, that if you want the resulting file to be automatically opened in the default program which is used to open *.png files in your system, you can call the StartProcess method, which is also shown in this example.

using System.Diagnostics;
using System.Drawing.Imaging;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...

private void ExportToPNG()
{
    // A path to export a report.
    string reportPath = "c:\\Test.png";

    // Create a report instance.
    XtraReport1 report = new XtraReport1();

    // Get its Image export options.
    ImageExportOptions imageOptions = report.ExportOptions.Image;

    // Set Image-specific export options.
    imageOptions.Format = ImageFormat.Png;

    // Export the report to Image.
    report.ExportToImage(reportPath);

    // Show the result.
    StartProcess(reportPath);
}

// Use this method if you want to automaically open
// the created Image file in the default program.
public void StartProcess(string path)
{
    Process process = new Process();
    try
    {
        process.StartInfo.FileName = path;
        process.Start();
        process.WaitForInputIdle();
    }
    catch { }
}
See Also