ChartControl.ExportToHtml(Stream, HtmlExportOptions) Method

Exports a chart to the specified stream in HTML format using the specified HTML-specific options.

Namespace: DevExpress.XtraCharts

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

Declaration

public void ExportToHtml(
    Stream stream,
    HtmlExportOptions options
)
Public Sub ExportToHtml(
    stream As Stream,
    options As HtmlExportOptions
)

Parameters

Name Type Description
stream Stream

A Stream object to which the created chart is exported.

options HtmlExportOptions

A HtmlExportOptions object which specifies the HTML export options to be applied when a chart 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.v20.2 assembly.

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

Examples

The following example demonstrates how to export a chart to HTML and MHT files. You may use similar methods in your applications to export a ChartControl as HTML of MHT.

using System.IO;
using DevExpress.XtraCharts;
using DevExpress.XtraPrinting;
// ...

private void ExportChartToHTML(ChartControl chart) {
    if (chart.IsPrintingAvailable) {
        // Create an object containing HTML export options.
        HtmlExportOptions htmlOptions = new HtmlExportOptions();

        // Set HTML-specific export options.
        htmlOptions.CharacterSet = "utf-8";
        htmlOptions.RemoveSecondarySymbols = false;
        htmlOptions.Title = "Unicode UTF-8 Example";

        // Export a chart to an HTML file.
        chart.ExportToHtml("OutputUnicode.html", htmlOptions);

        // Export a chart to a stream as HTML.
        using (FileStream htmlStream = new FileStream("OutputDefault.html", FileMode.Create)){
            chart.ExportToHtml(htmlStream, htmlOptions);
        }
    }
}


private void ExportChartToMHT(ChartControl chart) {
    if (chart.IsPrintingAvailable) {
        // Create an object containing MHT export options.
        MhtExportOptions mhtOptions = new MhtExportOptions();

        // Set MHT-specific export options.
        mhtOptions.CharacterSet = "iso-8859-1";
        mhtOptions.Title = "Unicode UTF-8 Example";

        // Export a chart to an MHT file.
        chart.ExportToMht("OutputUnicode.mht", mhtOptions);

        // Export a chart to a stream as MHT.
        using (FileStream mhtStream = new FileStream("OutputDefault.mht", FileMode.Create)){
            chart.ExportToMht(mhtStream, mhtOptions);
        }
    }
}
See Also