views:

261

answers:

2

I would like to generate an Open XML document containing a Chart using the Open Xml SDK 2. I found an SpreadsheetML example, but I can't work out how to add the chart in a .docx...

Is there a good source for documentation/examples for the Open Xml SDK 2?

+2  A: 

This article describes how to add a picture to WordProcessingML from an XML perspective: http://openxmldeveloper.org/articles/462.aspx

Actual code for the same thing using the Open XML API: http://msdn.microsoft.com/en-us/library/bb497430(office.14).aspx

If you've successfully added a chart to SpreadsheetML, you can adapt the picture example to do the same for WordProcessingML. You'll still have the a:graphic element that they have in their example. Contained inside, the a:graphicData will have a chart URI (http://schemas.openxmlformats.org/drawingml/2006/chart) instead of a picture URI. The data inside the a:graphicData will be identical to what you had for SpreadsheetML.

Wayne Kao