下面的示例演示了如何把图表导出为 HTML 和 MHT 文件。 可以在应用程序中使用类似的方法,把 ChartControl 导出为 HTML 或 MHT。
C# | 复制代码 |
---|
using System.IO;
using DevExpress.XtraCharts;
using DevExpress.XtraPrinting;
private void ExportChartToHTML(ChartControl chart) {
if (chart.IsPrintingAvailable) {
HtmlExportOptions htmlOptions = new HtmlExportOptions();
htmlOptions.CharacterSet = "utf-8";
htmlOptions.RemoveSecondarySymbols = false;
htmlOptions.Title = "Unicode UTF-8 Example";
chart.ExportToHtml("OutputUnicode.html", htmlOptions);
FileStream htmlStream = new FileStream("OutputDefault.html", FileMode.Create);
chart.ExportToHtml(htmlStream, htmlOptions);
}
}
private void ExportChartToMHT(ChartControl chart) {
if (chart.IsPrintingAvailable) {
MhtExportOptions mhtOptions = new MhtExportOptions();
mhtOptions.CharacterSet = "iso-8859-1";
mhtOptions.Title = "Unicode UTF-8 Example";
chart.ExportToMht("OutputUnicode.mht", mhtOptions);
FileStream mhtStream = new FileStream("OutputDefault.mht", FileMode.Create);
chart.ExportToMht(mhtStream, mhtOptions);
}
}
|
Visual Basic | 复制代码 |
---|
Imports System.IO
Imports DevExpress.XtraCharts
Imports DevExpress.XtraPrinting
Private Sub ExportChartToHTML(ByRef Chart As ChartControl)
If (Chart.IsPrintingAvailable) Then
Dim HtmlOptions As New HtmlExportOptions()
HtmlOptions.CharacterSet = "utf-8"
HtmlOptions.RemoveSecondarySymbols = False
HtmlOptions.Title = "Unicode UTF-8 Example"
Chart.ExportToHtml("OutputUnicode.html", HtmlOptions)
Dim HtmlStream As New FileStream("OutputDefault.html", FileMode.Create)
Chart.ExportToHtml(HtmlStream, HtmlOptions)
End If
End Sub
Private Sub ExportChartToMHT(ByRef Chart As ChartControl)
If (Chart.IsPrintingAvailable) Then
Dim MhtOptions As New MhtExportOptions()
MhtOptions.CharacterSet = "iso-8859-1"
MhtOptions.Title = "Unicode UTF-8 Example"
Chart.ExportToMht("OutputUnicode.mht", MhtOptions)
Dim MhtStream As New FileStream("OutputDefault.mht", FileMode.Create)
Chart.ExportToMht(MhtStream, MhtOptions)
End If
End Sub
|