gpt4 book ai didi

c# - 在 VSTO PowerPoint 中创建 map 图表

转载 作者:太空狗 更新时间:2023-10-29 19:42:08 24 4
gpt4 key购买 nike

我正在尝试在 PowerPoint 中添加 map 图表。

截至目前,我在 XlChartType 中看不到这样做的选项,但如果我手动插入一个,我可以检查插入的图表并查看其 XlChartType 计算结果为 140。

如果我尝试插入这种类型的图表,我会按预期得到 map 图表。但是,如果我尝试访问它的工作簿,它会抛出异常。这两行代码应该可以解释我在做什么:

var chart = _slide.Shapes.AddChart((XlChartType)140).Chart;
var workbook = (Workbook)chart.ChartData.Workbook;

我认为这与它不受官方支持有关。有没有办法解决这个问题并编辑图表的数据?

最佳答案

我认为您缺少对 Activate 方法的调用。

来自 official source 的结帐备注:

Note You must call the Activate method before referencing this property; otherwise, an error occurs.

您的代码应该是:

var chart = _slide.Shapes.AddChart((XlChartType)140).Chart;
chart.ChartData.Activate(); // missing piece
var workbook = (Workbook)chart.ChartData.Workbook;

关于c# - 在 VSTO PowerPoint 中创建 map 图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51963444/

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