Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / March 2005

Tip: Looking for answers? Try searching our database.

Excel Automation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DebugUnlimited - 11 Mar 2005 12:56 GMT
Hi All,

I have seen lots of thread on HOW TO automate Excel. Many has also provided
answers to that. But none had provided a generic way that does not depend
on the version of XL.
I need a sample that is able to automate XL irrespective of the version
installed on other machine.

Can any body help me on this.

Thanks
Fredrik Wahlgren - 11 Mar 2005 13:24 GMT
> Hi All,
>
[quoted text clipped - 7 lines]
>
> Thanks

As long as you use .NET and you refer to the PIA, you can't. If you just
want to make some user defined functions, no problem. If you want one
solution that works with many versions of Excel and has it's own menus, your
best bet is VB6. If you don't mind C++, you can create either COM and/or
automation add-ins as well as xll's

Please tell what you want to do in more detail.

Best Regards,
Fredrik
DebugUnlimited - 12 Mar 2005 06:18 GMT
Hi Fredrik!
I want to export data from  SQL server to XL in a predefined format.
If i refer to the PIA, it works fine. Incedentaly i have office 2003
installed on my 2nd machine and Office 2000 pro on my first development
machine. Now when i open the same project on the 2nd machine, ity shoots
out error message during build, which refers to the refrence i made for
office 2000.
This made me think what if the client has diff verisons installed at his
place? I have used GetObject in VB (dynamic binding) and need some sort of
same thing in .Net C#.

Any ideas?

Thanks
Andrew Hayes - 31 Mar 2005 06:57 GMT
Using Automation in C# is a pain, primarily because C# doesn't support
Optional parameters, and unfortunately MS usually just tagged on extra
parameters as Optional whenever they updated the automation interfaces.

This is why in VB6 you can late-bind an Excel object and the same method for
accessing the contents of a cell will work regardless of the version of
Excel.

There are reams of articles concerning Office Development with Visual
Studio:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnoxpta/html/vs
officedev.asp


but very little about using Visual Studio.NET.

Anyway, I digress. An article you might find of use is:

Binding for Office automation servers with Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;302902

You might want to look at this too:

Applied Remoting
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/v
bnet05272003.asp


Another solution that we have used ourselves is to write an Automation
wrapper in VB6 as an COM DLL that late-binds Excel and then reference it
from your C#.NET project. You have to do a big of jiggery-pokery to get the
COM component to expose it's interface so that C#.NET can use it, but apart
from that it works. Can't vouch for decent performance though since there's
lots of calls to IDispatch and other interfaces.

Regards...Andrew

P.S. Don't forget to modify the DCOM Config for the Microsoft Excel
Application.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.