NetOffice - version-independent interop assemblies

1,531 views
Skip to first unread message

Govert van Drimmelen

unread,
Jun 30, 2011, 8:44:00 AM6/30/11
to Excel-DNA
Hi Excel-DNA Users,

I've just noticed a very intruiging project on CodePlex called
NetOffice at http://netoffice.codeplex.com.

It looks like a very comprehensive solution to building some version
independent interop assemblies for all the Office apps. This should
make a perfect complement to Excel-DNA, giving you a few small
assemblies to reference (or pack in your .xll) and getting full access
to the object model on all versions of Excel.
MIT license, so no issues to use anywhere.

For now I just want to add the pointer - I'm not sure when I can have
a closer look.
I'd really appreciate if any of the Excel-DNA gurus could investigate
a bit, and perhaps write up an example. It looks like an excellent
implementation of one of the pieces we've been waiting for.

Thanks,
Govert

Ronan Mouquet

unread,
Jun 30, 2011, 9:00:41 AM6/30/11
to exce...@googlegroups.com
Hi Govert,

What a coincidence, I was just complaining about the fact that I could have to deploy 3 different versions of the PIA according to Excel version !
I think I will test it next week.

Cheers
Ron



--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To post to this group, send email to exce...@googlegroups.com.
To unsubscribe from this group, send email to exceldna+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/exceldna?hl=en.


Ron

unread,
Jul 4, 2011, 9:46:39 AM7/4/11
to Excel-DNA
Hi Govert,

I played a little bit with NetOffice : I removed all the references to
"Excel" or "Office.Core" assemblies from my project and replaced with
the NetOffice ones.

I made the tests on 2 machines :
1) Windows XP + office 2003
2) Windows 7 + office 2010

I will describe below what I used in NetOffice. The whole application
works as before, in both platforms. The only issue is that I cannot
remove the PIAs from the Windows Program manager and I didn't want to
manually remove them from Regedit. So I will have to test the whole
program on a virgin machine (maybe tomorrow).

To know :
1) The "Application" class in NetOffice is a wrapper to the Excel one.
Easy to create :
new Application(null, ExcelDnaUtil.Application);

2) Before creating the "Application" instance, the following line of
code has to be run :
LateBindingApi.Core.Factory.Initialize();

3) All the events have been renamed with "Event" at the end. Ex:
WorkbookActivateEvent instead of WorkbookActivate

4) The enums are in another workspace than the objects :
NetOffice.ExcelApi for excel objects, NetOffice.ExcelApi.Enums for
enums.

5) The COMExceptions seem to be catched and rethrown. So if you had a
"catch(System.Runtime.InteropServices.COMException)", and it was my
case, now you have to catch a TargetInvocationException. Not very
funny...

These are the only changes I had to make to my code (plus the
references) and it works !

How do I use NetOffice (coupled with DNA) :
1) Create a new worksheet, write tables, draw borders, color cells and
write formulas. Rename the sheet. Hide and unhide it.
2) Open an existing workbook
3) Add a contextual menu
4) Add a menu bar with many items including sub-menus
5) Call for UDFs through DNA (and the call will automatically format
the calling cell), using XlCall.Excel(XlCall.xlfCaller) etc.
6) Use RTD server
7) Make a com server and call to the UDFs from VBA

It would be take time to make small examples for all of that but there
are a lot of examples in the sources provided by NetOffice.

So Govert, do you plane to move to NetOffice ?

Regards
Ron


On Jun 30, 2:00 pm, Ronan Mouquet <ronan.mouq...@gmail.com> wrote:
> Hi Govert,
>
> What a coincidence, I was just complaining about the fact that I could have
> to deploy 3 different versions of the PIA according to Excel version !
> I think I will test it next week.
>
> Cheers
> Ron
>
> On Thu, Jun 30, 2011 at 1:44 PM, Govert van Drimmelen <gov...@icon.co.za>wrote:
>
> > Hi Excel-DNA Users,
>
> > I've just noticed a very intruiging project on CodePlex called
> > NetOffice athttp://netoffice.codeplex.com.

Govert van Drimmelen

unread,
Jul 6, 2011, 5:10:03 AM7/6/11
to Excel-DNA
Hi Ron,

Thanks for having a look and posting back with the tricks to make it
work!
Using NetOffice from Excel-DNA sounds promising.

My main interest would be the VBA->Excel-DNA portability story.
The exception remapping and namespace changes should not be a problem
there.
Why do you think the event names got changed / have the -Event suffix?

> So Govert, do you plane to move to NetOffice ?

For my own stuff I've been calling the Excel automation interfaces
late-bound from VB.NET, which works great. And with the 'dynamic' type
in C# 4, that also helps a lot.

But for the general Excel-DNA story I've not really had any solution.
I know Add-In Express has some version-independent interop stuff.
Every time I looked at making something like that it looked like a lot
of work, and I've been happy with the late-bound calls so far.
If it works well, I think NetOffice would be a wonderful complement to
Excel-DNA. And from what you report it sounds very good.

Have you tried to put the NetOffice libraries in a packed single-
file .xll?

-Govert

Sebastian Unknown

unread,
Jul 6, 2011, 9:52:08 AM7/6/11
to Excel-DNA
5) The COMExceptions seem to be catched and rethrown. So if you had a
"catch(System.Runtime.InteropServices.COMException)", and it was my
case, now you have to catch a TargetInvocationException. Not very
funny...

yes now i see, interop dll throws always COMException and wrap inner
COM server exception(s)
i doesnt do anything with exceptions from COM server currently.
is an issue now. http://netoffice.codeplex.com/workitem/16220

fix needs 1 day.

Sebastian Unknown

unread,
Jul 8, 2011, 4:23:14 AM7/8/11
to Excel-DNA
Release 1.0 with fixed issue 16220 is now available.

Yinru Hou

unread,
Jul 8, 2011, 11:33:48 AM7/8/11
to exce...@googlegroups.com
Hi, Ron:

Do you have to replace NetOffice dll for 64 bit?

thanks

Ron

unread,
Jul 8, 2011, 12:06:14 PM7/8/11
to Excel-DNA
Hi Yinru,

I used the same NetOffice dlls for all my tests. Windows 7 was 64
bits, but Excel was 32 bits. I don't currently have any 64 bits
version of Excel for my tests, but I think Excel APIs are the same.

I am sure that Sebastian has a lot of good information about that
purpose !

Regards
Ron


On Jul 8, 4:33 pm, Yinru Hou <yinru...@gmail.com> wrote:
> Hi, Ron:
>
> Do you have to replace NetOffice dll for 64 bit?
>
> thanks
>

Ron

unread,
Jul 8, 2011, 12:13:57 PM7/8/11
to Excel-DNA
Thanks Sebastian. Now I receive a COMException as before.
I didn't notice any regression for what I am using.

Cheers
Ron


On Jul 8, 9:23 am, Sebastian Unknown <sebastiandot...@googlemail.com>
wrote:

Yinru Hou

unread,
Jul 8, 2011, 12:23:42 PM7/8/11
to exce...@googlegroups.com
Hi, Sebastian:
I will take a look at netoffice after current release (Mid-July)
My current AddIn works for 32 bit office and we plan to support 64 bit.
Does netoffice have two sets of dll to support 32 bit, 64 bit respectively or just one set which works for both 32 bit and 64 bit office?

thanks


On Fri, Jul 8, 2011 at 3:23 AM, Sebastian Unknown <sebasti...@googlemail.com> wrote:
Release 1.0 with fixed issue 16220 is now available.

Sebastian Unknown

unread,
Jul 8, 2011, 5:10:10 PM7/8/11
to Excel-DNA
NetOffice is also platform independent.
but your COMAddin has to compiled in 2 versions
please read the (small)documentation for further info :
http://netoffice.codeplex.com/wikipage?title=Tec_Documentation_English_32Bit_64Bit
> >http://groups.google.com/group/exceldna?hl=en.- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Govert van Drimmelen

unread,
Jul 8, 2011, 5:55:08 PM7/8/11
to Excel-DNA
For Excel-DNA, this means you can use the same NetOffice .dll on all
platforms, but you still have to use the 32-bit or 64-bit version of
the ExcelDna.xll file, matching the bitness of your Excel version.

On Jul 8, 11:10 pm, Sebastian Unknown <sebastiandot...@googlemail.com>
wrote:
> NetOffice is also platform independent.
> but your COMAddin has to compiled in 2 versions
> please read the (small)documentation for further info :http://netoffice.codeplex.com/wikipage?title=Tec_Documentation_Englis...
>
> On 8 Jul., 18:23, Yinru Hou <yinru...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi, Sebastian:
> > I will take a look at netoffice after current release (Mid-July)
> > My current AddIn works for 32 bit office and we plan to support 64 bit.
> > Does netoffice have two sets of dll to support 32 bit, 64 bit respectively
> > or just one set which works for both 32 bit and 64 bit office?
>
> > thanks
>
> > On Fri, Jul 8, 2011 at 3:23 AM, Sebastian Unknown <
>
> > sebastiandot...@googlemail.com> wrote:
> > > Release 1.0 with fixed issue 16220 is now available.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Excel-DNA" group.
> > > To post to this group, send email to exce...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > exceldna+u...@googlegroups.com.
> > > For more options, visit this group at
> > >http://groups.google.com/group/exceldna?hl=en.-Zitierten Text ausblenden -

kissinger chen

unread,
Feb 28, 2016, 1:29:22 AM2/28/16
to Excel-DNA
Hi Ron,

Could you share me your sample codes? I am interested to combine .net DNA and net office together.

Thanks.

Kissinger
Reply all
Reply to author
Forward
0 new messages