NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
will.nevis
Posts: 7
0 Kudos

efficiency of using activeX for Excel

I've been using data logging for our test fixtures in .tsv files, but our engineers want to automate it further by organizing some new data into several sheets, so I'm looking into manipulating Excel directly using ActiveX.

 

 

My question is how efficient is it to write this in ActiveX compared to just making a text file? I'm concerned that, since we're going to be writing some 50000 cells or something, that it'll suck up a lot of memory to do it through ActiveX. 

 

Is this a legitimate concern, or am I just being paranoid?

-----------------------
Anything worth doing is worth over-doing.

LabVIEW Junkie
Trusted Enthusiast
mikeporter
Posts: 3,823
0 Kudos

Re: efficiency of using activeX for Excel

You are not being paranoid the ActiveX performance into Excel stinks. How about saving to TDMS and using the Excel plugin to read it in.

Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

mlportersr@gmail.com

"Safe? Who said anything about 'safe'? 'Course he's not safe - but he is good..."
Active Participant nyc
Active Participant
Posts: 1,570
0 Kudos

Re: efficiency of using activeX for Excel


will.nevis wrote:

I've been using data logging for our test fixtures in .tsv files, but our engineers want to automate it further by organizing some new data into several sheets, so I'm looking into manipulating Excel directly using ActiveX.

 

 

My question is how efficient is it to write this in ActiveX compared to just making a text file? I'm concerned that, since we're going to be writing some 50000 cells or something, that it'll suck up a lot of memory to do it through ActiveX. 

 

Is this a legitimate concern, or am I just being paranoid?


Writing to a text file means you won't be able to have worksheets in an Excel file.

 

I found with using ActiveX in Visual Basic 6 to write to an actual Excel file, and not just a text *.csv, that there is a time penalty if you don't know how to do the write properly. You need to use arrays and write to a a range in Excel in one shot so to speak. The same most likely applies to LabVIEW as well.

 

I don't have the code with me at home, but if you are interested, I can look for the actual command when I am at work tomorrow.

 

 

Active Participant
Akiel
Posts: 299
0 Kudos

Re: efficiency of using activeX for Excel

I have a performance critical system, and the way round a major impact on performance (as far as I can tell ) I have used is a producer/consumer to have the system continuously sample, read values back at a regular rate (e.g. 50ms but obviously depends on your application) and stream them into a TDMS file. This is in excel format. Once testing is complete or your passed the performance critical phase the excel can be processed into whatever format your engineers would like.

 

Hope it helps

 

TD 

Please remember to accept any solutions and give kudos, Thanks


LV 8.6.1, LV2010,LV2011SP1, FPGA, Win7
Member
will.nevis
Posts: 7
0 Kudos

Re: efficiency of using activeX for Excel

Thanks for all the help, guys! 

 

A couple of things -- first off, I'd love to look at that code if you get a chance. But what I'm concerned about is if I create an array of 50000 values or something like that and write it all in one go at the end of the program, two things are going to happen: 1) it's going to take a really long time to finish the program, and 2) if the program crashes in that final step, I'll lose all the data. That second reason is why I currently write a line every cycle to the .tsv file. 

 

What I'm thinking of doing, is meeting you halfway -- rather than write each cell individually, write each line individually within the spreadsheet. This should reduce the memory used (hopefully) and increase performance.

 

 

I haven't really played around with TDMS yet, I'll look into it. A couple questions on that -- does it write in excel format? The reason I ask is the second sheet that I'm supposed to add is not going to contain any changing data -- it's just to store some constants that are set on the front panel. If TDMS stores data in excel format, I can write it to TDMS, transfer to Excel, and then use ActiveX to add the second worksheet with the constants at the end of the program. How's that sound?

 

Thanks again!

-----------------------
Anything worth doing is worth over-doing.

LabVIEW Junkie
Knight of NI
Knight of NI
Ben
Posts: 16,091
0 Kudos

Re: efficiency of using activeX for Excel


will.nevis wrote:

... 

I haven't really played around with TDMS yet, I'll look into it. A couple questions on that -- does it write in excel format? The reason I ask is the second sheet that I'm supposed to add is not going to contain any changing data -- it's just to store some constants that are set on the front panel. If TDMS stores data in excel format, I can write it to TDMS, transfer to Excel, and then use ActiveX to add the second worksheet with the constants at the end of the program. How's that sound?

 

Thanks again!


 

I'll also confirm the speed of writing Excel via ActiveX sucks. It one of the few times I actull put up a message telling user this could take a long time.

 

There is a plug-in that allow Excel to read TDMS.

 

Your proposed approach sounds good to me.

 

Ben

 

Ben Rayner
Who is NOT John Galt... yet... just building Rayner's Ridge

Active Participant
Puneet_K
Posts: 224
0 Kudos

Re: efficiency of using activeX for Excel

You should implement 'Excel VBA Macro' for your data analyzing & call them from LabVIEW.

Which will more efficient rather then calling excel with activeX objects.

 

http://msdn.microsoft.com/en-us/library/aa220713%28v=office.11%29.aspx

------------------------------------------
CLD 2012
Active Participant nyc
Active Participant
Posts: 1,570
0 Kudos

Re: efficiency of using activeX for Excel


will.nevis wrote:A couple of things -- first off, I'd love to look at that code if you get a chance.

I cut the Excel write time by using xlWorksheet.Range(strCell1, strCell2).Value = fValues in VB6 where fValues is a one-dimensional array, but it should be possible to be modified to be a 2-dimensional array.

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page