Skip to main content
A newer version of this page is available.

ChartControl.ExportToXls(Stream) Method

Creates an XLS document with a chart inserted as an image and sends it to a stream.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v18.2.UI.dll

Declaration

public void ExportToXls(
    Stream stream
)

Parameters

Name Type Description
stream Stream

A Stream object to which the created document is exported.

Remarks

To show the standard Print dialog, use the ChartControl.Print method. The dialog allows end-users to print the chart, select the printer (if required), specify the range of pages to print, the number of copies, etc.

To display the DevExpress Print Preview use one of the following methods.

Method Description
ChartControl.ShowPrintPreview Creates the print document and displays the Print Preview of the document.
ChartControl.ShowRibbonPrintPreview Creates the print document and displays the Print Preview with the Ribbon toolbar of the document.

To export the chart, use the appropriate ExportTo~ method (e.g., ChartControl.ExportToHtml, ChartControl.ExportToPdf, etc.)

Important

Note that, exporting to raster and vector images is implemented by the Chart and does not require any library.

The chart can be previewed, printed and exported to other formats only if the Printing library is available. Make sure you add a reference to the DevExpress.XtraPrinting.v18.2 assembly.

Also note that chart export to PDF requires the DevExpress.Pdf.Core library to be available.

Example

The following example demonstrates how to export a chart image inserted into XLS document to either a file or a stream.

using System.IO;
// ...

if (chartControl1.IsPrintingAvailable){
    // Exports to an XLS file.
    chartControl1.ExportToXls("Output.xls");

    // Exports to a stream as XLS.
    FileStream xlsStream = new FileStream("Output.xls", FileMode.Create);
    chartControl1.ExportToXls(xlsStream);
    // ...

    xlsStream.Close();
}
See Also