Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon May 12, 2014 7:53 pm

Does the Spire.XLS API allow developers the ability to insert existing Word documents into an Excel Spreadsheet as OleObject? If so, can I add each document in separate rows?

Alex51482
 
Posts: 2
Joined: Mon May 12, 2014 7:50 pm

Tue May 13, 2014 3:29 am

Hello,

Thanks for your inquiry.
Our product supports the feature. Please kindly try our Spire.Office component(http://www.e-iceblue.com/Download/downl ... t-now.html).
Share sample code regarding the feature.
Code: Select all
static void Main(string[] args)
        {
            Workbook workBook = new Workbook();
            string docxFile1 = @"..\..\Sample1.docx";
            string docxFile2 = @"..\..\Sample2.docx";

            Image image1 = GetDocImage(docxFile1);
            Image image2 = GetDocImage(docxFile2);

            Worksheet sheet= workBook.Worksheets[0];
           
            IOleObject oleObject1 = sheet.OleObjects.Add(docxFile1, image1, OleLinkType.Embed);
            oleObject1.ObjectType = OleObjectType.WordDocument;

            sheet= workBook.Worksheets[1];

            IOleObject oleObject2 = sheet.OleObjects.Add(docxFile2, image2, OleLinkType.Link);
            oleObject2.ObjectType = OleObjectType.WordDocument;

            workBook.SaveToFile("sample.xlsx", ExcelVersion.Version2007);
            System.Diagnostics.Process.Start("sample.xlsx");
        }
          private static Image GetDocImage(String docxFile)
        {
            Document document = new Document();
            document.LoadFromFile(docxFile);
            return document.SaveToImages(0, Spire.Doc.Documents.ImageType.Bitmap);
        }


Please feel free to contact us for further inquiry.

Best wishes,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Wed May 14, 2014 3:47 pm

Hey Amy

So I am creating a new Excel Spreadsheet from an existing Database and I want to add the OleObject Word document on a specific column.

So I have a generic List and I want to manually create columns with information on new Excel Spreadsheet, one of those columns will have the OleObject Word Document.

Would you happen to have such a sample?

Thank you

Alex51482
 
Posts: 2
Joined: Mon May 12, 2014 7:50 pm

Thu May 15, 2014 3:11 am

Hello,

Thanks for your response.
Sorry that at present our component has not achieved that let every OleObject Word document on a specific cell yet.

Best wishes,
Amy
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS