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

Free Support Forum - aspose.com

Load document from byte array

hi there,

i am loading a document template from a database, like explained in the article
How to load and save a document to database

now my problem:
if the template contains an Excel worksheet object, this object is converted to an image.
what can i do?

Hi Birgit,


Thanks for your inquiry. I think, you can use the following code to extract those embedded excel objects and save them to separate files on disk:

// Get collection of shapes

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

// to be able to read and save MS Excel files to disk<o:p></o:p>

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

}

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

}


I hope, this helps.

Best Regards,

thx a lot, but that doesn’t help at all, because i don’t want to extract the Excel object. all i want to do is using the document template to create a serial letter, which means that, if the template contains an Excel object, it should be an Excel object after processing the merge fields.
i broke the problem down to creating a document object from your words library, so the merge field filling should be the next step, but the problem is generated by the document object.

Hi Birgit,


Thanks for your inquiry and sorry for the delayed response. Aspose.Words preserves the Excel OLE objects that is embedded inside Word documents during open/save. We have just released Aspose.Words v11.9.0; could you please upgrade to the latest version of Aspose.Words and let us know how it goes on your side? You can download it from the following link:
http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/default.aspx

Best Regards,