Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Oct 25, 2023 1:58 pm

Description:

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)

dmrejen
 
Posts: 2
Joined: Wed Sep 13, 2017 10:25 am

Thu Oct 26, 2023 5:48 am

Hi,

Thanks for your inquiry.

Currently, our doc product only supports adding DocPicture as an OLE icon. Unfortunately, it does not support direct display of OLE content.

If you have any other questions or require assistance, please feel free to let us know. We are here to help.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Thu Oct 26, 2023 5:53 am

Hello Triste,

Just to conform OLE icon mean on double clicking it can open source file correct? That's what I needed. Can you please let me know if that's correct and if yes then how can I achieve that?

Thanks

dmrejen
 
Posts: 2
Joined: Wed Sep 13, 2017 10:25 am

Thu Oct 26, 2023 6:11 am

Hi,

Thanks for your feedback.

Your understanding is correct. Please refer to the tutorial: https://www.e-iceblue.com/Tutorials/Spire.Doc/Spire.Doc-Program-Guide/NET-Word-Insert-OLE-Object-in-Word-with-C-VB.NET.html

Please feel free to post back if you have any questions.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.Doc