Hi Team
can you please share sample code on how to update excel sheet which is inside word doc.
thanks
Hi Team
can you please share sample code on how to update excel sheet which is inside word doc.
thanks
Hi Yatin,
// 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 component<o:p></o:p>
// to be able to convert MS Excel files to separate HTML files<o:p></o:p>
}<o:p></o:p>
}
}<o:p></o:p>
}
DocumentBuilder builder = new DocumentBuilder(doc);<o:p></o:p>
Stream memoryStream = File.OpenRead(MyDir + “Book1.xls”);<o:p></o:p>
Shape oleObject = builder.InsertOleObject(memoryStream, “Excel.Sheet.8”, true, null);<o:p></o:p>
doc.Save(MyDir + @“out.docx”);Hi Awais,
Hi
Can you. Please reply as we need to complete a poc urgently.
thanks
Hi Yatin,
DocumentBuilder builder = new DocumentBuilder(doc);<o:p></o:p>
Stream memoryStream = File.OpenRead(MyDir + “Book1.xls”);<o:p></o:p>
Shape oleObject = builder.InsertOleObject(memoryStream, “Excel.Sheet.8”, true, null);<o:p></o:p>
doc.Save(MyDir + @“out.docx”);