下面的示例演示了如何把图表作为插入到 XLS 文档中的图像导出到文件或流。

C#CopyCode image复制代码
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();
}
Visual BasicCopyCode image复制代码
Imports System.IO
' ...

If chartControl1.IsPrintingAvailable Then
    ' Exports to an XLS file.
    chartControl1.ExportToXls("Output.xls")

    ' Exports to a stream as XLS.
    Dim xlsStream As FileStream = New FileStream("Output.xls", FileMode.Create)
    chartControl1.ExportToXls(xlsStream)
    ' ...

    xlsStream.Close
End If