LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing to Excel using ActiveX improvement?

Hello,

 

At my company we have Labview 2011 basic version with DAQmx. I am writing a program to get temperature data from thermocouples (16), dump it in an array and then store it in Excel using ActiveX. ActiveX seems only to allow writing element by element to my spreadsheet.  When you do acquisition for a long period of time it can be very long! I like using ActiveX because it allows some flexibility such as choosing which sheet and cell I can write my data. Is there a solution to dump the array in one operation using ActiveX?

 

I know there is a block call write to spreadsheet which accept 1D and 2D array of data but doesn't allow the same flexibility. I also found report generation but is it made to write data? While waiting for your answer I'll try to dig a little more that blockset.

 

Thank you very much and I hope to hear from the community really soon.


Regards

0 Kudos
Message 1 of 6
(3,272 Views)

You can use the ActiveX _Worksheet Method in conjuction with the Range Property in order to write a 2D array of data to an Excel Worksheet.Excel.PNG

Message 2 of 6
(3,262 Views)
Wow! Thanks for the quick reply. Last time I tried to use the Range/Cell2 property it wrote the array first element from cell 1 to cell 2. I'll try again. Thanks again!
0 Kudos
Message 3 of 6
(3,256 Views)

It worked just fine... I don't know what I did wrong before. Many thanks!

0 Kudos
Message 4 of 6
(3,251 Views)

Then please mark Electromecha's message as the solution to your problem rather than your own thank you message.  First, you'll need to go to the options menu to the upper right of your message and pick Unmark as Solution.

0 Kudos
Message 5 of 6
(3,231 Views)

I have to appologize. The solution given by Electromecha was good but only outside a loop. Again, I have 16 thermocouples and when I use Electromecha's solution inside a For loop it will copy only the first element. I attached two pictures. One is the program and the second is the result in the spreadsheet. You will notice that inside my loop I added an indicator to read the array before writing it in Excel. The indicator shows the array perfectly with all elements in it. The only way I found to work around this issue is to use indexing and write element by element in Excel. That is way too long!

 

For your information, the loop itteration is defined using the array size which is 16 (for 16 thermocouples). The subvi inside the loop allows me to get the column letter from the itteration number. Finally using the size of one full array of results I get the end cell row. 

 

If more explanation is required please let me know. 

 

Many thanks!

Download All
0 Kudos
Message 6 of 6
(3,186 Views)