Search code examples
excelpdfembeddingxls

Embedding a PDF file in Excel .xls using C#


Anyone have any tips for how to embed PDF files in a .xls Excel spreadsheet using C#?


Solution

  • For those that need the answer, here it is....

    Application xlApp = new Application();
    xlApp.DisplayAlerts = false;
    
    Workbook book = xlApp.Workbooks.Open(@"C:\test5.xls", 2, false);
    
    Worksheet sheet = book.Worksheets[1];
    
    sheet.Shapes.AddOLEObject(Filename: @"C:\test.pdf", Height: 400, Width: 400);
    
    book.Save();
    ....
    ....
    ....