0

我已经搜索了一段时间,但无法确定如何将使用 c# 在 Visual Studio 2010 中创建的图表导出到 Excel 文件中。这是创建我的图表的代码

chart1.ChartAreas.Add("zz");
            chart1.ChartAreas["zz"].AxisX.Minimum = 0;
            chart1.ChartAreas["zz"].AxisX.Interval = 1;
            chart1.ChartAreas["zz"].AxisY.Minimum = 0;

            chart1.Series.Add("q");
            chart1.Series.Add("w");

            chart1.Series["q"].Color = Color.Aqua;
            chart1.Series["w"].Color = Color.BurlyWood;

            chart1.Series["q"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;
            chart1.Series["w"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;

            for (int j = 0; j < textAdded.Count; j++)
            {
                chart1.Series["q"].Points.AddXY(j + 1, Convert.ToDouble(textAdded[j]));
                chart1.Series["w"].Points.AddXY(j + 1, Convert.ToDouble(textAdded2[j]));
            }  string ppt_fName = @"U:\ChartAdd.pptx";
            PowerPoint.Application myPPT = new PowerPoint.Application();
            myPPT.Visible = MsoTriState.msoTrue;
            myPPT.Presentations.Open(ppt_fName);


            PowerPoint.Slide s = myPPT.ActiveWindow.View.Slide;
            PowerPoint.Chart ctrng = null;
            //fails due to cast problem
            ctrng = (PowerPoint.Chart)chart1;

它不允许我将图表添加到 powerpoint 幻灯片上,并且想知道如何实现这一点

4

1 回答 1

0

您可以将图表保存为图像,然后将图像添加到您的 powerpoint。

于 2012-10-09T12:12:07.567 回答