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

Free Support Forum - aspose.com

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<o:p></o:p>

NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);<o:p></o:p>

int i = 0;<o:p></o:p>

//Loop through all shapes<o:p></o:p>

foreach (Shape shape in shapes)<o:p></o:p>

{<o:p></o:p>

if (shape.OleFormat != null)<o:p></o:p>

{<o:p></o:p>

if (!shape.OleFormat.IsLink)<o:p></o:p>

{<o:p></o:p>

//Extract OLE Word object<o:p></o:p>

if (shape.OleFormat.ProgId == “Word.Document.12”)<o:p></o:p>

{<o:p></o:p>

MemoryStream stream = new MemoryStream();<o:p></o:p>

shape.OleFormat.Save(stream);<o:p></o:p>

Document newDoc = new Document(stream);<o:p></o:p>

newDoc.Save(string.Format(@“C:\test\outEmbeded_{0}.html”, i));<o:p></o:p>

i++;<o:p></o:p>

}<o:p></o:p>

//Extract OLE Excel object<o:p></o:p>

if (shape.OleFormat.ProgId == “Excel.Sheet.12”)<o:p></o:p>

{<o:p></o:p>

// Here you can use Aspose.Cells API<o:p></o:p>

// to be able to extract Chart as an Image<o:p></o:p>

}<o:p></o:p>

}

}<o:p></o:p>

}


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,