Free Support Forum -

Not able to track chart within excel sheet, embedded in word using c#


My concern is, I have a docx file containing one or more linked charts referencing to my Excel sheet. I m trying to fetch that chart from Excel by reading the chart in Ms Word using Aspose.Words.
How will I be able to track, that My chart 1 belongs to which sheet of the Excel.
Even, after reading the chart from Word, I am not able to read it as a chart, but Aspose.Words is reading it as an image.
Because of this, I am getting Shape…OleFormat as null.
Please help me with this.
Thanks in advance


I am afraid, your query is not clear enough. We request you to please elaborate your query further by providing complete details of the use case. Also, please ZIP and upload your sample Word and Excel files here for our reference. This will help us to understand your question and we will be in better position to address your concerns accordingly.

Thank you for your reply.

My exact use case:
We are a financial service company producing financial research for clients. Our Analysts work out company models in Microsoft Excel and then finally prepare a word document report which is then distributed to clients in form of PDF or word. All charts and tables are copied from excel in docx file as embedded objects. Now, our goal is to convert those documents to HTML to be uploaded on our website. An analyst can have multiple supporting excels for single report.

We tried using Aspose.Cells and were able to retrieve all charts and tables from excel files. We were also successful in creating HTML file by exporting all charts as SVG files and tables in HTML format.

However, the exact sequence of charts and tables required is in form of report in docx file. So, our goal now is to extract all embedded objects from docx file, get the excel path, sheet name and chart/table id/name to exactly retrieve contents from relevant excel files.

Find attached zip sample word and excel file.
I have an Excel sheet with some tables and generated charts out of those tables. I copied some of those charts from Excel to a separate Word file as a Linked chart.
My task is to read all the charts from word file using Aspose.Words and get the reference of those charts from Excel File so that I can convert the Excel chart into an SVG file using Aspose.Cells.
To Read the linked Charts from the Word file and get the reference of its relevant Excel file, I created the following C# function,

public void ReadVectorImages(string docx, string outputDirectory)
Aspose.Words.Document doc = new Aspose.Words.Document(docx);
NodeCollection nodes = doc.GetChildNodes(NodeType.Shape, true);
int i = 1;
foreach (var node in nodes)
Aspose.Words.Drawing.Shape shapeNode = node as Aspose.Words.Drawing.Shape;

            if (shapeNode.HasChart)  //Always getting as False, even though it's a chart
                     string str = shapeNode.OleFormat.SourceFullName;

                  // Some code to process Excel


Through this function, I am getting Excel file path, which is not enough to me, because, I need to get the Sheet Number/ Name and the Chart Name / ID within that sheet to read the Exact chart further through Aspose.Cells.
So, I didn’t find any property or function name to track the same.

My another concern with regards to Aspose.Words is, even though my above function is reading all the shapes from Word files, but it’s property HasChart is always coming as false, even though my docx file has chart. Because of that, I cannot process further to track the Excel file.

Awaiting your advise on above use case and problem explained above.


I am afraid, we do not see any attachments from you in this thread.

You may upload the ZIP file (containing Word/Excel documents etc) to Dropbox and share the download link here for testing. (586.0 KB)

Please find my Attached Zip file


Well these are not really represented as ‘Charts’ in Word document. You can use the following simple code to get file path of linked Excel file:

Document doc = new Document("D:\\aspose\\Doc2.docx");
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
foreach (Shape shape in shapes)
    if (shape.OleFormat != null)
        if (shape.OleFormat.IsLink)
            string filePath = shape.OleFormat.SourceFullName;

            // Here you can load Excel file into Aspose.Cells DOM and do further processing

Thank you very much for your quick reply.

But, I would like to address my another concern about getting the Sheet ID / Name and the Link ID / Name itself through some property of OleFormat or some other way round. By the mentioned code, I am just getting the full path of the Excel file, but not getting the Sheet ID/Name and the Link ID/Name to exact track that link in excel using Aspose.Cells. Because My Excel file may have many sheets and a single sheet may have multiple links.

awaiting for your valuable advise


Along with Shape.OleFormat.SourceFullName property, you can use Shape.OleFormat.SourceItem property to identify the portion of the source file that is being linked. You can write logic to extract required information from this property. Does this help?