C#:MS Chart:SeriesCollection - > InvalidCastException的?

时间:2012-12-11 22:03:48

标签: c# mschart excel-interop .net

在PPT 2010中获取char系列的正确方法是什么。

我试过

PowerPoint.SeriesCollection mySeriesCollection = (PowerPoint.SeriesCollection)
                                                           myChart.SeriesCollection(1);

抛出以下异常

Exception Type:        System.InvalidCastException

此外,在C#中获取图表系列的正确调用是什么?

如果我这样试试:

PowerPoint.Series mySeries = (PowerPoint.Series)myChart.SeriesCollection.Item(1);

我收到以下编译错误:

error CS0119: 'Microsoft.Office.Interop.PowerPoint.Chart.SeriesCollection(object)'
is a 'method', which is not valid in the given context

1 个答案:

答案 0 :(得分:0)

你很亲密;你需要以第一种方式调用SeriesCollection方法,然后转向第二种方式。

PowerPoint.Series mySeries = (PowerPoint.Series)myChart.SeriesCollection(1);