10-05-2015 04:15 AM
Hi Everyone,
I'm currently looking into ways how to read cells (or complete tables) from Excel. The communication with Excel through ActiveX is well documented and there are many examples online which I could use. My first question would be: Is there any drawback in implementing this in ActiveX over .Net?
Somehow I have it in my head that ActiveX is "old technology" and it would make more sense to implement this in .Net. In my head the advantages of .Net are that my program will be easier to maintain in the future as well as slightly better performance wise. However, I don't have the knowledge to back it up, so I'd be happy if you could weigh in.
Thanks in Advance.
Solved! Go to Solution.
10-05-2015 08:27 AM
@PeterFoerster wrote:
Hi Everyone,
I'm currently looking into ways how to read cells (or complete tables) from Excel. The communication with Excel through ActiveX is well documented and there are many examples online which I could use. My first question would be: Is there any drawback in implementing this in ActiveX over .Net?
Somehow I have it in my head that ActiveX is "old technology" and it would make more sense to implement this in .Net. In my head the advantages of .Net are that my program will be easier to maintain in the future as well as slightly better performance wise. However, I don't have the knowledge to back it up, so I'd be happy if you could weigh in.
Thanks in Advance.
What do you mean by ActiveX over .NET ?
If you were programming in .NET, you'd still need to use ActiveX.
10-05-2015 08:29 AM
If you have access to the Report Generation Toolkit (included in the LabVIEW "base" starting with LabVIEW 2014), this is (in my opinion) by far the easier (and better) way to go for doing 95% of the things you want to do linking LabVIEW and Excel.
We use Excel Workbooks to "program" behavioral studies of (human) sound localization. Each row corresponds to a Trial, with about 100 parameters (timing, placement of the sound source, nature of the sound stimulus, production of other sound and visual stimuli during the trial, plus a limited set of "outcome measures") defining each trial. When we first developed this system (with LabVIEW 7.0), ActiveX was the way you linked LabVIEW and Excel. It was tricky, relatively slow (it might take a second to read and parse a row, particularly if reading and writing was involved), and a pain to maintain and modify.
About 3 years ago, we began a complete rewrite of this code using "modern" LabVIEW, including using the revised Report Object-based Report Generation Toolkit. It now takes a few hundredths of a second to read/write a row, the code is much simpler and much more flexible, and was much easier to develop.
I believe ActiveX is no longer in active support or development by Microsoft. I certainly know that when we migrated to Windows 7, I had a difficult time finding the appropriate Help files that would let me know what all those "interesting" ActiveX functions were and how they worked (I did eventually find the information). What the story with Windows 8 and 10 are, I don't know.
As far as examples go, there are also numerous examples on the Forum doing Excel things with the Report Generation Toolkit (I posted a number of them, myself). So that's my $0.02 worth of opinion.
Bob Schor
10-05-2015 08:41 AM
OK, so I seem to fundamentally have misunderstood something: From a LabVIEW standpoint, there's the .Net palette and the activeX palette. So I have the coice of loading and then using .Net assemblies and using ActiveX objects. So far everything I did in both .net and activeX was exclusive: I programed one, without even having to know the other exists. Accordingly I thought that they were two separate things. In terms of using the two in other languages such as C# it is the same way.
Now, your answer suggests that the two are connected- which they might as well be without me ever having to know it. Does the .Net interface to excel use the activeX interface? Then the .net interface would just be a wrapper and I might as well use the activeX components that I know to work in LabVIEW instead of struggling with the .Net assembly.
10-05-2015 11:12 AM
Well, here is the 4 simple RGT way to read the first Sheet of a named Excel Workbook into a 2D array of Strings. You would need to do a little more work if you wanted to do something other than read everything, and if the data were known to be all numerics, you might find it more convenient to wire an array of numerics to the Excel Read Data function. But why do it the easy, LabVIEW-centric way if there's .NET and ActiveX?
Bob Schor
10-06-2015 01:04 AM
Hi Bob,
thanks for the example. I started writing my answer to nyc's post and before I published it you must have posted yours. I couldn't write an answer to that, because I had no time.
So, both your example and your sarcasm have been well received!
As for nyc's post, I still don't understand the connection, but I'd like to...
10-06-2015 08:40 AM
As for nyc's post, I still don't understand the connection, but I'd like to...
http://digital.ni.com/public.nsf/allkb/D984CF1CA889B809862565FC0078E964
http://stackoverflow.com/questions/1670940/what-is-the-interop-dll
10-06-2015 08:58 AM
Thanks for the additional Info. Good to accumulate some more knowledge, next time I work with an interop assembly I'll know better.
Since I'll be working with the RGT I won't have to go into too much detail anyway.