tags:

views:

30

answers:

1

We have a requirement, in which we need to create dynamic word document and these word documents contains Table, Chart, text and images to be replace/update dynamically. So we decided to create a template and place text holders at dynamic places. To create new document by reading and updating Template we decided to go for OpenXML SDK 2.0.

I am successfully able to replace/update Text/Table and Image content (for place holder tagging we are using Content Controls and we assign a unique tag to each content control.)

I am still trying to figure out, how we will modify the chart data. As far as i know about chart part, it has its own underlying xlx data file, in which it stores the data. So now to update chart part i can think of three different solutions.

1.) Update underlying xlx file by using Open SDK. I am not sure if this can be done or not, but considering its just an xlx file, so i should be able to modify it using Open XML Sdk itself.

2.) Create a chart, convert into image and then replace the image.

3.) I have also read about Custom XML, in which we can bind Content Controls with that XML. So the idea is to create a chart with Custom XML as datasource and then update data xml dynamically.

Any suggestions or Code samples would be appreciated. I am using Open XML SDK 2.0.

A: 

I tried with approach1, I modified the underlying xlsx data, but seems it was not sufficient as under Chart.xml -> ChartSpace -> Chart-> PlotArea -> BarChart -> BarChartSeries -> Values, it was saving those numeric values. So i guess i am missing a component, which can read from xlsx and then updates chart accordingly. For now i have manually updated the both xlsx and Values so that it is reflected properly.

Nitin Midha