> 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.