Adding Reference to Excel - which one?

M

mickieparis

Hello, when adding a reference to Excel in a project there are two
choices, one is under the .Net tab for Interop and the other is under
the COM tab. I would like to know the difference between the two. Is
there a good tutorial somewhere?

Basically I have data from SQL db in a datatable and I just need to
update a few cells in an existing excel spreadsheet. I tried to use
ADO.net and Oledb but that requires setting up the spreadsheet a
certain way (like a table with row headers) and the spreadsheet is not
setup like that.

Thanks,
Michelle
 
G

Gregory A. Beamer

mickieparis said:
Hello, when adding a reference to Excel in a project there are two
choices, one is under the .Net tab for Interop and the other is under
the COM tab. I would like to know the difference between the two. Is
there a good tutorial somewhere?

Basically I have data from SQL db in a datatable and I just need to
update a few cells in an existing excel spreadsheet. I tried to use
ADO.net and Oledb but that requires setting up the spreadsheet a
certain way (like a table with row headers) and the spreadsheet is not
setup like that.

If you add a COM component reference, it will create an interop library, or
what is termed as a ".NET callable wrapper". If an interop assembly is
provided by the manufacturer, it is generally the best way to go, as they
may have optimized certain things that tlbimp.exe will not do (the tool you
can create a .NET callable wrapper with and the tool VS uses to create the
assemblies called interop).

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

************************************************
| Think outside the box! |
************************************************
 
M

mickieparis

Well, in this case the Mfg. is Microsoft. As I said, I just need to
update a few cells with some values but there are two choices when
added a reference. Which one should I use?

Michelle
 
P

Peter Duniho

mickieparis said:
Well, in this case the Mfg. is Microsoft. As I said, I just need to
update a few cells with some values but there are two choices when
added a reference. Which one should I use?

As Gregory explained, a specific .NET interop library is generally
preferable over a COM library.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top