在 PowerPoint2010 Shape & 中访问图表数据VSTO
我必须格式化位于 Shape
内部的饼图(更改数据标签的字体,更改饼图内的颜色等)。我有一个代码片段:
foreach (Shape s in Selection.SlideRange.Shapes)
{
if (s.HasChart == Microsoft.Office.Core.MsoTriState.msoTrue)
{
Excel.Workbook workbook = s.Chart.ChartData. as Excel.Workbook;
}
}
s.Chart
is not null。但是,当我调用 ChartData
属性时,出现异常:
's.Chart.ChartData.Workbook' threw an exception of type 'System.Runtime.InteropServices.COMException'
如何真正获取 Chart
基础数据和属性?
I have to format Pie Chart that is located inside Shape
(change font of Data labels, change colors inside pie chart etc). I have a code snippet:
foreach (Shape s in Selection.SlideRange.Shapes)
{
if (s.HasChart == Microsoft.Office.Core.MsoTriState.msoTrue)
{
Excel.Workbook workbook = s.Chart.ChartData. as Excel.Workbook;
}
}
s.Chart
is not null. However when I call ChartData
property I get an exception:
's.Chart.ChartData.Workbook' threw an exception of type 'System.Runtime.InteropServices.COMException'
How can I actually get Chart
underlying data and properties?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我记得 shape.Chart.ChartData 是一个 ChartData 对象,而不是 Excel.Workbook,但它有一个名为 Workbook 的属性。您可以在此处找到一个简短的示例:如何更新 PowerPoint使用c#绘制图表
As far as I remember shape.Chart.ChartData is a ChartData object not an Excel.Workbook but it has a property named Workbook. You can find a short sample here: How to update PowerPoint chart using c#