We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Re: Updating chart in word document

HI Aspose Team,


I am also working on word doc chart. I have already designed bar chart and want to update the chart text and values dynamically in c#. I need your help. I have a Aspose Total for .NET license. My client asking me to do it. I was getting same feature in OpenXML SDK. so if you don’t have such feature then what is the worth for paying you so much license fee.

Thanks,
Tika
Hi Tika,

Thanks for your inquiry. Could you please attach your input and expected output Word documents here for our reference? We will then provide you more information about your query and log the feature in our issue tracking system accordingly.

My code for updating docx bar chart text and values with new values :


public ActionResult GetReport()
{
string templateSource = System.Web.HttpContext.Current.Server.MapPath("/App_Data/add charts.docx");

Document doc = new Document(templateSource);

var shapes = doc.GetChildNodes(NodeType.Shape, true);

var altTitle = new List();

foreach (Shape shape in shapes)
{
if (shape.HasChart)
{
shape.Chart.Series[0].DataLabels. ?? = 5;
var a = shape.Chart.Series[0];
a.Name = “Test”;

}
}

Response.ContentType = “text/plain; charset=UTF-8”;
Response.AddHeader(“content-disposition”, “attachment;filename=”" + “Report.docx” + “”");
Response.Clear();
doc.Save(Response.OutputStream, SaveFormat.Docx);
Response.End();
return null;
}
Hi Tika,

Thanks for sharing the detail. Unfortunately, Aspose.Words does not support the requested features at the moment. However, we have logged these features in our issue tracking system as follow:

WORDSNET-14399 : Add feature to update value of ChartDataLabel
WORDSNET-14398 : Add feature to update chart's data

You will be notified via this forum thread once these features are available. We apologize for your inconvenience.

If you want to update the chart's series values, we suggest you please remove them by using ChartSeriesCollection.Clear method and insert new series to chart. Please refer to the following article.
Working with Charts

Thank you for your reply, I will go to next option, actually I already did, however how to get bar color, I guess it would be default color, is there any way to apply bar color that we want to ?

Hi Tika,

Thanks for your inquiry. Unfortunately, Aspose.Words does not support the requested feature at the moment. However, we have logged this feature request as WORDSNET-12275 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-12275) have been fixed in this Aspose.Words for .NET 21.6 update and this Aspose.Words for Java 21.6 update.