【问题标题】:add visual studio chart to powerpoint将 Visual Studio 图表添加到 PowerPoint
【发布时间】:2012-10-09 20:17:03
【问题描述】:

我已经搜索了一段时间,但无法确定如何将使用 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 幻灯片上,我想知道如何实现这一点

【问题讨论】:

  • 如何创建图表??
  • 我已经提交了创建我的图表的代码
  • 是否可以将图表从 c# 直接添加到 powerpoint?我的印象是,那是不可能的(可悲的)。您可以尝试互操作(慢!)或 epplus(更快,但只有 xlsx 文件)

标签: c# visual-studio-2010 charts powerpoint


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-11
    • 1970-01-01
    相关资源
    最近更新 更多