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

Free Support Forum - aspose.com

How can I Modify MS Graph Chart Values

I have a word document that includes some MS Graph Chart Objects (MSGraph.Chart.8)

I want to modify the Datasheet values of the Charts using Aspose.Words.

Can you please explain me how can i do this?


Hi Abdennacer,

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-14398 in our issue tracking system. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

As a workaround, we suggest you please remove the chart’s series using ChartSeriesCollection.Clear method and insert new series to chart. Hope this helps you. Please refer to the following article.
Working with Charts

Hi Tahir,

Thank you very much for your Reply. Can you please tell me how can i get the chart from the MS Graph Object, so i can remove the series?

I try it with this code, but it doesn’t work.

Bookmark bmchart1 = doc.Range.Bookmarks["chart1"];
Paragraph chart_object = (Paragraph)bmchart1.BookmarkStart.GetAncestor(NodeType.Paragraph);
for (int i = 0; i < chart_object.ChildNodes.Count; i++)
    // Skip first and last nodes
    if (i == 0 || i == chart_object.ChildNodes.Count - 1) continue;
    Shape shape = (Shape)chart_object.ChildNodes[i];
    // Check if the current shape has OLE object
    if (shape.OleFormat == null) continue;
    // Determine extenfion of the object.
    if (shape.OleFormat.ProgId.Equals("MSGraph.Chart.8"))


Hi Abdennacer,

Thanks for your inquiry. Could you please share your input document here for our reference? We will then provide you more information about your query along with code example.

Hi Tahir,

Thank you very much for your Reply. I attached the input Document to this Message, it is a dot Document (EVU_WD10.dot) with a set of Bookmars.

The Bookmarks can be a Table, MS Graph Chart, TOC etc, and have to be filled with Data from a Database with C#.


Hi Abdennacer,

Thanks for sharing the detail. You can move the cursor to the bookmark and insert the table, TOC field, charts etc. Please refer to the following articles:
Using DocumentBuilder to Modify a Document Easily

Unfortunately, Aspose.Words does not provide API to update “MS Graph Chart”. However, we have logged this feature request as WORDSNET-15433 in our issue tracking system. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.

Hi Abdennacer,

In your case, we suggest you following solution. Hope this helps you.

  1. Move the cursor to the Shape node that have MSGraph.Chart.8 ProgId.

  2. Save the OLE document into stream object.

  3. Use Aspose.Words to update the Excel document. Please see the highlighted code snippet below and refer to the following article.
    Import Data into Worksheet

  4. Insert the updated Excel document as OLE into the Word document using DocumentBuilder.InsertOleObject method.

Please check the following code example.

Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
Node[] shapes = doc.GetChildNodes(NodeType.Shape, true).ToArray();
foreach (Shape shape in shapes)
    if (shape.OleFormat != null && shape.OleFormat.ProgId.Equals("MSGraph.Chart.8"))
        MemoryStream stream = new MemoryStream();
        stream.Seek(0, SeekOrigin.Begin);
        // Update the Excel document using Aspose.Cells
        // You need to update these values according to your OLE (excel document)
        Aspose.Cells.Workbook newExcelDoc = new Aspose.Cells.Workbook(stream);
        Aspose.Cells.Worksheet sheet = newExcelDoc.Worksheets[0];
        sheet.Cells["A1"].Value = "Test value changed";
        stream.Position = 0;
        newExcelDoc.Save(stream, Aspose.Cells.SaveFormat.Excel97To2003);
        // Render the sheet to image for OLE image
        Aspose.Cells.Rendering.ImageOrPrintOptions imgOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();
        imgOptions.Quality = 100;
        imgOptions.VerticalResolution = 800;
        imgOptions.HorizontalResolution = 800;
        // Specify the image format
        imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
        // Only one page for the whole sheet would be rendered
        imgOptions.OnePagePerSheet = true;
        imgOptions.PrintingPage = Aspose.Cells.PrintingPageType.IgnoreBlank;
        sheet.PageSetup.TopMargin = 0;
        sheet.PageSetup.BottomMargin = 0;
        sheet.PageSetup.LeftMargin = 0;
        sheet.PageSetup.RightMargin = 0;
        Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(sheet, imgOptions);
        // Render the image for the sheet
        Bitmap bitmap = sr.ToImage(0);
        builder.InsertOleObject(stream, "MSGraph.Chart.8", false, bitmap);
doc.Save(MyDir + "Out.docx");

Hi @tahir.manzoor,
is there any news about the feature requested WORDSNET-14398?

@nick89 Unfortunately, there are no news regarding this issue yet. The issue is postponed and not yet scheduled for development. We will keep you informed and let you know once there are news regarding it.

The issues you have found earlier (filed as WORDSNET-14398) have been fixed in this Aspose.Words for .NET 23.5 update also available on NuGet.