简体   繁体   中英

to open an excel file, what is the difference between these 2 assemblies

when adding a reference I see:

.net tab

microsoft.office.tools.excel

is that the one I need to read a excel file?

other posts seem to be using a COM assembly with 'interop' in it?

The Interop one is available on the COM tab if you have Excel installed. It will be "Microsoft Excel 12.0 Object Library" or similar. The version number represents the version of Office so make sure you get the one you're after, though Office should be backwards compatible if you select an older one.

This will give you a reference under the references folder of: Microsoft.Office.Interop.Excel

Microsoft.Office.Tools.Excel is part of Visual Studio Tools for Office. This is a Managed wrapper around Office applications so you can extend them using C# but only works with Office 2003 upwards.

Microsoft.Office.Interop.Excel is a direct COM interop assembly which provides access to the entire Excel Automation model through the COM interface.

The first option is probably the easiest to use but I don't think it contains all the functionality of the second.

Another option would be to open the Excel file using ADO.NET cia the JET datasource. This would mean querying the sheet as though each worksheet was a database table rather than accessing through the normal Row/Cell object model.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM