如何通过属于Microsoft.Office.Interop.Excel的ChartObject获取Excel图表配置

时间:2016-07-26 06:45:20

标签: c# excel vsto

这是一个包含一个工作表的excel文件,也包含工作表中的一些数据。 然后用户创建一个图表,就像'xlLine'或'xlColumnClustered'一样,并设置一些配置信息,如图表标题,CategoryTitle,ValueTitle等。 我怎样才能获得配置信息,尤其是图表的选定数据区域? THS!

the worksheet and chart

some code

        //Get the current worksheet
        Microsoft.Office.Tools.Excel.Worksheet worksheet = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet);
        //Get ChartObjects 
        Microsoft.Office.Interop.Excel.ChartObjects objs = (ChartObjects)worksheet.ChartObjects(Type.Missing);
        //Just get the first ChartObject
        Microsoft.Office.Interop.Excel.ChartObject obj = objs.Item(1);
        //Get the chartTitle
        string chartTitle = obj.Chart.ChartTitle.Caption;

0 个答案:

没有答案