获取瀑布图类别名称
Get category names of waterfall chart
我正在尝试读取 PowerPoint VSTO 项目中瀑布图的类别名称。
到目前为止,我无法这样做。
这是我尝试过的:
chart.SeriesCollection(x).Axes(y).CategoryNames
- 不适用于此图表类型
chart.SeriesCollection(x).XValues
- 不适用于此图表类型
chart.SeriesCollection(x).Points(y).DataLabel.Text
/ .Caption
- 这个 returns 点值,而不是类别名称,例如-130
chart.SeriesCollection(x).DataLabels(y).Text
/ .Caption
- 与之前相同:它 returns 点值
然后,我尝试通过chart.ChartData.Workbook
直接读取源数据,但是这也不可用。
那么,如何读取类别名称?
在撰写本文时,XlChartType enumeration 似乎缺少 Waterfall 的成员。 (Waterfall 有一个 ChartType
整数值 119,在枚举中根本就没有。)
由于缺少枚举会产生各种问题,我决定编写代码将图表转换为枚举类型,将类别名称放入数组中,然后使用 PowerPoint 的 Undo
功能来恢复图表。
PowerPoint.Chart myChart = Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes[2].Chart;
myChart.ChartType = Office.XlChartType.xlBarStacked;
PowerPoint.Axis CategoryAxis = Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes[2].Chart.Axes(PowerPoint.XlAxisType.xlCategory, PowerPoint.XlAxisGroup.xlPrimary);
Array CatNames = (Array)((object)CategoryAxis.CategoryNames);
Globals.ThisAddIn.Application.CommandBars.ExecuteMso("Undo");
//Do something here with the CatNames array
我正在尝试读取 PowerPoint VSTO 项目中瀑布图的类别名称。
到目前为止,我无法这样做。
这是我尝试过的:
chart.SeriesCollection(x).Axes(y).CategoryNames
- 不适用于此图表类型chart.SeriesCollection(x).XValues
- 不适用于此图表类型chart.SeriesCollection(x).Points(y).DataLabel.Text
/.Caption
- 这个 returns 点值,而不是类别名称,例如-130chart.SeriesCollection(x).DataLabels(y).Text
/.Caption
- 与之前相同:它 returns 点值
然后,我尝试通过chart.ChartData.Workbook
直接读取源数据,但是这也不可用。
那么,如何读取类别名称?
在撰写本文时,XlChartType enumeration 似乎缺少 Waterfall 的成员。 (Waterfall 有一个 ChartType
整数值 119,在枚举中根本就没有。)
由于缺少枚举会产生各种问题,我决定编写代码将图表转换为枚举类型,将类别名称放入数组中,然后使用 PowerPoint 的 Undo
功能来恢复图表。
PowerPoint.Chart myChart = Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes[2].Chart;
myChart.ChartType = Office.XlChartType.xlBarStacked;
PowerPoint.Axis CategoryAxis = Globals.ThisAddIn.Application.ActivePresentation.Slides[1].Shapes[2].Chart.Axes(PowerPoint.XlAxisType.xlCategory, PowerPoint.XlAxisGroup.xlPrimary);
Array CatNames = (Array)((object)CategoryAxis.CategoryNames);
Globals.ThisAddIn.Application.CommandBars.ExecuteMso("Undo");
//Do something here with the CatNames array