VSTO/Excel: 获取Excel图表中的某个点的数据

前几天有位朋友发邮件给我,问的这个问题,代码弄的差不多了,但碰到一个几天都没琢磨出来的问题:

Excel.ChartObject chartObject = (Excel.ChartObject)Globals.Sheet1.ChartObjects(1);
Excel.Chart chart = chartObject.Chart;
Excel.Series series = chart.SeriesCollection(1);
foreach (object item in (object[])series.Values)
{

}
问题出在第四行,Locals里显示series.Values是一个object[],但(object[])series.Values报Unable to cast object of type ‘System.Object[*]‘ to type ‘System.Object[]‘错误。
Google了好久,找到一个和我碰到相同问题的,但我试了他的(Array)series.Values这个方法,并不能解决,仍然报错,(object[,])series.Values也不行。

哪位朋友也碰到这个问题的,麻烦教我一下解决方法。

系统环境: WIN XP + VS2010 + Office2010

posted @ 2010-08-07 09:30  RobinLao  阅读(1600)  评论(4编辑  收藏  举报