gpt4 book ai didi

vba - 获取瀑布图的类别名称

转载 作者:行者123 更新时间:2023-12-01 03:14:48 26 4
gpt4 key购买 nike

我正在尝试读取 PowerPoint VSTO 项目中瀑布图的类别名称。
到目前为止,我无法这样做。

这是我尝试过的:

  • chart.SeriesCollection(x).Axes(y).CategoryNames - 不适用于此图表类型
  • chart.SeriesCollection(x).XValues - 不适用于此图表类型
  • chart.SeriesCollection(x).Points(y).DataLabel.Text/.Caption - 这将返回点值,而不是类别名称,例如-130
  • chart.SeriesCollection(x).DataLabels(y).Text/.Caption - 同上:返回点值

  • 然后,我尝试通过 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

    关于vba - 获取瀑布图的类别名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49411763/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com