Quantcast
Channel: Open XML Format SDK forum
Viewing all articles
Browse latest Browse all 1288

How to add a Horizontal Bar Chart to Word.docx to be updated in code?

$
0
0

Hi,

How can a chart be put onto openxml Word doc?  I can create a blank or dummy chart to put there and try to sort thru to get into the values, but how is it done?

Goal:  to add a 1-100% stacked Horiz bar chart with 3 series.  

I have a docx used as a template, i copy this into a memory stream, then search into that to find elements.   So far adding a Chart has failed, the resulting docx is "corrupt".  To find the location to add something, I had added string literals in the word doc but made the font invisible.

so "put_item_here" is tiny and white as the background.

foreach (DocumentFormat.OpenXml.OpenXmlElement xde in bodyDoc)
     {
        if (xde.InnerText == "put_item_here")
          { xde.InsertAfterSelf(GenerateTheChart());
          }
So the problem is HOW to add a Chart?  I made the method GenerateTheChart(), I took a blank Word doc and added a chart, saved it, opened in OpenXml sdk tool to get at the code, but putting this into the method worked for Tables, but its not working for the chart.


Viewing all articles
Browse latest Browse all 1288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>