Extract Chart from docx file

Hi,

How to extract the chart image from a docx file with good quality using Aspose words?

Thanks

Hi Sriram,

Thanks for your inquiry. You can extract embedded Excel document from Word document and load it inside Aspose.Cells DOM using following code:

Document doc = new Document("in.docx");
// Get collection of shapes
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
int i = 0;
// Loop through all shapes
foreach (Shape shape in shapes)
{
    if (shape.OleFormat != null)
    {
        if (!shape.OleFormat.IsLink)
        {
            // Extract OLE Word object
            if (shape.OleFormat.ProgId == "Word.Document.12")
            {
                MemoryStream stream = new MemoryStream();
                shape.OleFormat.Save(stream);
                Document newDoc = new Document(stream);
                newDoc.Save(string.Format(@"C:\test\outEmbeded_{0}.html", i));
                i++;
            }
            // Extract OLE Excel object
            if (shape.OleFormat.ProgId == "Excel.Sheet.12")
            {
                // Here you can use Aspose.Cells API
                // to be able to extract Chart as an Image
            }
        }
    }
}

Please refer to the following articles:

Converting Chart to Image using Aspose.Cells
Convert an Excel Chart to Image using Aspose.Cells

Hope, this helps.

Best regards,