开发者

How to change PowerPoint chart data with .NET?

I have a PowerPoint template that contains one slide and on that slide is a chart. I'd like to be able to manipulate that chart's data using .NET.

So far I have code that...

  1. unzips the Powerpoint file.
  2. unzips the embedded excel file (ppt\embeddings\Microsoft_Office_Excel_Worksheet1.xlsx)
  3. It successfully manipulates the data in the excel sheet and zips it back up.
  4. Opens and manipulates ppt\charts\chart1.xml
  5. Powerpoint is then zipped up and delivered to the user
开发者_JAVA百科

The result of this is a PowerPoint file that shows a blank chart. But when I click on the chart and go to edit data it updates the data and shows the correct chart.

I believe my problem is with the chart1.xml that I am generating. I have compared my generated version with a version created by PowerPoint and they are almost identical. The only differences are in the values for <c:crossAx/> and <c:axId/>.

There are also some rounding differences in the data. But I do not feel like that would result in a blank chart.

Is there another file that I need to edit? Does anyone have any ideas as to what else I should try to get this working?


It's likely a combination the axID value and the rounding issues. The Axis ID, likely, is asking for an integer value and you may be supplying a single/double. So the cached data in chart1.xml doesn't know how to display.

Try your same manipulation that you've been doing, but instead of opening the result in PowerPoint, change the .pptx extention to .zip, unzip and then manually fix the rounding issues to match the original rounding. Then zip back up, change extension back to .pptx and open in PowerPoint. If this fixes the issue of display, you can confirm it is the rounding issue.

Alternatively, and along the same lines. Open your resulting PPTX in PowerPoint as you have been doing, and once you've right-clicked and rehydrated the chart, save as a different file name and compare that with your automated result.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜