I am currently facing a critical issue while trying to link an Excel object in a Word document using Spire.doc. The issue is preventing me from delivering a project to a client, and I need urgent assistance to resolve it.
Detailed Explanation:
I have followed the steps below to link an Excel object from Excel to Word using Spire.doc:
- Manually copied Excel cells.
Special pasted the cells into Word as a link to stay connected with Excel.
Opened the Word document using Spire.doc.
Attempted to find the Excel object using Spire's code.
However, during step 4, I can see the URL of the Excel file, but it lacks the exact cell location information in the URL. Furthermore, when I save the document using Spire, the Excel object appears as an image in the document and is not connected as a link.
Desired Outcome:
I need a solution to create a linked Excel object in a Word document using Spire.doc. This linked object should remain connected to the original Excel file, and any updates made in Excel should reflect in the Word document. It is exporting excel object in word as an Image whereas I need that as a linked object.
Code Sample:
Here is a simplified version of the code I am using in my project for reference:
- Code: Select all
Spire.Doc.Document doc = new Spire.Doc.Document();
using (FileStream fileStream = File.OpenRead("D:\\Template.docx"))
{
doc.LoadFromStream(fileStream, Spire.Doc.FileFormat.Docx2019);
foreach (Spire.Doc.Section sec in doc.Sections)
{
foreach (Spire.Doc.Documents.Paragraph paragraph in sec.Paragraphs)
{
foreach (Spire.Doc.DocumentObject obj in paragraph.ChildObjects)
{
if (obj.DocumentObjectType == Spire.Doc.Documents.DocumentObjectType.OleObject)
{
Spire.Doc.Fields.DocOleObject Ole = obj as Spire.Doc.Fields.DocOleObject;
if (Ole.ObjectType == "Excel.Sheet.12")
{
doc.SaveToFile("D:\\Template_Result.docx");
}
}
}
}
}
}
Severity: High
Urgency: Critical (Client Delivery Pending)