techno
techno

Reputation: 6500

Cannot Load Workbook from Excel File - Office.Interop.excel

I'm using Office Interop for Excel Version 15.0.0.0

There is no option to create a workbook from an Existing File.The old sample code uses the following method to create a workbook

Workbook workbook = new Workbook();
workbook.LoadFromFile(@"D:\MyExcel\SurfaceSample.xls");

This method --> LoadFromFile has been removed from the current library,also the open method is a delegate.I have refereed the documentation but cannot find a relevant method.

Upvotes: 0

Views: 1855

Answers (1)

Cindy Meister
Cindy Meister

Reputation: 25663

The Office object models don't work the same as those of the .NET Framework. For one thing, the New keyword should never be used for anything except the Application.

In order to create a new object (copy) from an existing file, Office applications provide the Add method. So something more like:

Workbook wb = xlApp.Workbooks.Add(filePathToTemplate);

Upvotes: 2

Related Questions