TeeChart for .NET为开发人员提供了可导出图表数据到Excel的功能,当导出时可以包含序列的标签、数据点的序列以及标题等,基本上通过简单的几句代码就可以实现了,部分关键代码如下:
private void button1_Click(object sender, System.EventArgs e)
{
saveFileDialog1.DefaultExt = tChart1.Export.Data.Excel.FileExtension;
saveFileDialog1.FileName = tChart1.Name+ "."+saveFileDialog1.DefaultExt;
saveFileDialog1.Filter="Excel files (*.xls)|*.xls";
if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
{
tChart1.Export.Data.Excel.Series = null; // export all series
tChart1.Export.Data.Excel.IncludeLabels = checkBox1.Checked;
tChart1.Export.Data.Excel.IncludeIndex = checkBox2.Checked;
tChart1.Export.Data.Excel.IncludeHeader = checkBox3.Checked;
tChart1.Export.Data.Excel.Save(this.saveFileDialog1.FileName);
}
}