I want to select existing Chart in Excel using C#. I have a chart Object in my excel file which I want to read it and also Edit it. I only know to add new chart which is by doing something like this
我想使用C#在Excel中选择现有的图表。我在我的excel文件中有一个图表对象,我想读它并编辑它。我只知道通过做这样的事情来添加新的图表
ChartObjects ChartObjs = null;
ChartObject ChartObj = null;
ChartObj = ChartObjs.Add(0, 10, 250, 170);
I am using VS 2005 and C#
我正在使用VS 2005和C#
2 个解决方案
#1
2
To select an active chart in excel one can use this code
要在Excel中选择活动图表,可以使用此代码
Excel.ChartObject chartObject11 = (Excel.ChartObject)Ws.ChartObjects(1);
chartObject11.Activate();
based on this one can edit the chart and format it.Like changing its datarange or formatting its color or height or width etc etc.
基于此可以编辑图表并格式化它。就像更改其数据范围或格式化其颜色或高度或宽度等。
Hope this helps
希望这可以帮助
#2
0
So you've defined an object named ChartObj. The chart within the chart object container is ChartObj.Chart, and elements of the chart are ChartObj.Chart.Element.
所以你已经定义了一个名为ChartObj的对象。图表对象容器中的图表是ChartObj.Chart,图表的元素是ChartObj.Chart.Element。
You ought to have Excel's VB Editor open so you can check syntax in the VB Object Browser.
您应该打开Excel的VB编辑器,以便在VB对象浏览器中检查语法。
#1
2
To select an active chart in excel one can use this code
要在Excel中选择活动图表,可以使用此代码
Excel.ChartObject chartObject11 = (Excel.ChartObject)Ws.ChartObjects(1);
chartObject11.Activate();
based on this one can edit the chart and format it.Like changing its datarange or formatting its color or height or width etc etc.
基于此可以编辑图表并格式化它。就像更改其数据范围或格式化其颜色或高度或宽度等。
Hope this helps
希望这可以帮助
#2
0
So you've defined an object named ChartObj. The chart within the chart object container is ChartObj.Chart, and elements of the chart are ChartObj.Chart.Element.
所以你已经定义了一个名为ChartObj的对象。图表对象容器中的图表是ChartObj.Chart,图表的元素是ChartObj.Chart.Element。
You ought to have Excel's VB Editor open so you can check syntax in the VB Object Browser.
您应该打开Excel的VB编辑器,以便在VB对象浏览器中检查语法。