Dynamic Charts in Word


#1

Hi,

How can we update the data of an embedded chart in a word document?


#2

@Pavithra_R_S

We suggest you please remove the chart series and add them again. Please check the following code example and read the following article.
Working with Charts

Document document = new Document(MyDir + "input.docx");

Shape shape = (Shape)document.GetChild(NodeType.Shape, 0, true);

if (shape.HasChart)
{
    Chart chart = shape.Chart;
    chart.Series.Clear();
    String[] types = new String[] { "text1", "text2", "text3" };
    double[] values = new double[] { 10d, 7d, 5d };
    ChartSeries ser0 = chart.Series.Add("test", types, values);
}

document.Save(MyDir + "out.docx");