Update Data behind an embedded Chart in an Open XML WordprocessingML Document

I’ve been lurking over at OpenXMLDeveloper.org, answering questions.  A fairly involved question came up recently, which is: If you have an embedded chart in a word-processing document, how do you update the data behind the chart?  As it turns out, you have to update the data in two different places.  You have to update the data in the embedded spreadsheet, and you have to update cached values in the word-processing document.

I’ve written a post on OpenXMLDeveloper.org that contains example to update the data and update the cached values.  In addition, I recorded the following screencast, which walks through the process:

Walks through the process of updating the data behind a chart that is embedded in an Open XML WordprocessingML document.



  1. Fordy said,

    June 14, 2012 @ 9:20 am

    Great example, it was exactly what I was looking for. Plugged the code into my project, tweaked it for my needs and it worked brilliantly. Many thanks for posting, must have saved me a couple of days work at least! A cheque’s in the post 😉

  2. JP said,

    August 28, 2013 @ 9:16 pm

    Eric, thanks so much for this example; I’ve been tasked with doing this and your demo got me over quite a few hudles!

    I have two issues I’m trying to sort out right now and was hoping you could point me in a direction.

    My document is goinging to have several charts so I’m trying to figure out a clean methodology to get at specific charts. I’ve got it looping through charts sequentially, so I could do it that way, but I’m hoping for something a bit less fragile. I was playing around with the “Title” attribute on the chart and thought perhaps I could search for it that way (it shows up in the XML), but I’m fairly new to OpenXML and and unsure how to proceed.

    I’m having the same problem as somone who posted on the page of this demo. When I download and run your example, it completes, but when I open the document I get a pop-up complaing that the document is corrupt. I OK past that and get a second pop-up asking if I’d like to recover the doc. I ask it to do that and the document opens and the table is updated as if nothing is wrong.

    So it winds up OK, but my users are not going to be happy about the corrupted document warnings. I was wondering what I could do to fix that.

    Thanks again, and any help you can point my way would be very much appreciated.


  3. raul said,

    September 30, 2014 @ 4:26 pm

    Eric, thanks so much for this example. This example is for update a chart and its data embedded excel.
    How do I update the image (.emf) of an object embedded excel?
    I am able to render the report and embed it in the PowerPoint presentation, but I cannot work out how to update the “excel preview image” that come along with the embedded excel sheet.

RSS feed for comments on this post · TrackBack URI

Leave a Comment