LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I write an array of strings to a single Excel row?

I'd like to write test data, as an array of strings, to an Excel file. Attached is my attempt to modify one of the Labview 6.1 example files. This modified example will write the data to the correct row, which is determined by serial # of the UUT, but to a new sheet for each unit. I'd like to do the same thing, but to just one sheet. This sheet's data would then be saved after 50 rows of collected test data.
 
 
Thank you in advance,
 
Tim Denson
 
0 Kudos
Message 1 of 16
(3,821 Views)
Instead of using ActiveX, try just writing the data to a tab separated ASCII file that Excel can easily open.

Look at the attached VI. It will create a file and write an array of data to it, then add more lines. You should be able to adopt this setup to fit your needs. If you save the data file with a. xls extension, it will open in Excel.

Let me know if this works for you. ActiveX can be a problematic. A security update from MS can change the ActiveX components and break your VI.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 2 of 16
(3,786 Views)

Hi Ed,

Thanks for your suggestion, however, I failed to fully explain why I was trying to get ActiveX to work. I've attached the spreadsheet, which has column labels. Because of these labels, I need to be able to select at which row the data starts. The example you provided worked as long as the labels were not present. The labels must be present on each report. Are there any other suggestions?

Thank you so much,
 
Tim
0 Kudos
Message 3 of 16
(3,776 Views)

Hi Tim,

The Write File VI that Ed used in his example has an input called "pos mode".  This input determines the position at which the new data is written in the file.  If you wire a 1 to this input, then the Write File VI will add your data at the end of the current file.  I think that this will work for you, you'll just need to be sure to start with an end line to begin a new row in the file. 

I hope this helps.  Please post if you have further questions or if I'm not clear on the situation.

Good luck!
Megan B.
National Instruments

0 Kudos
Message 4 of 16
(3,757 Views)
You need to save your file as a development distribution(.llb) so that we get all of the sub vi's
Message 5 of 16
(3,749 Views)

I've tried modifying Ed's example, as Megan suggested, but the Excel file gets scrambled when I write to it. I've attached the development distribution(.llb) of the ActiveX example I was working with before, as unclebump requested. Thank you all for your help.

Tim

 

0 Kudos
Message 6 of 16
(3,640 Views)

Here's the ActiveX (.llb)

Tim

 

 

 

0 Kudos
Message 7 of 16
(3,639 Views)
Would LabVIEW Report Generation Toolkit for Microsoft Office help me? Any input would be greatly appreciated.
 
Thank you,
 
Tim
 
 
0 Kudos
Message 8 of 16
(3,588 Views)

Hi Tim,

Yes, what you're trying to accomplish would be very easy with the Report Generation Toolkit.  You can specify row/cell locations in a worksheet where you want data to be added.  You can also "name" some cells in your worksheet, and you can insert data at locations identified by names.

Let me know if you want any more information about the Report Generation Toolkit,
-D

Message 9 of 16
(3,581 Views)
Sorry I didn't get back to faster on this. I've been out of town working and just really haven't had time.

Yes,

The Report Generation toolkit would make this very easy. If you have it, I'd suggest using it.

The image shown below shows the five VIs from the toolkit that I've used to write to Excel.



What this loop does is receive a string through a Queue, either open a template or open todays file, convert the tab delimited string to an array, write the array to the next line of the Excel file, Save (with todays date stamp if opened from the tempate) and close it. It's a good idea to always save and close teh file after each write if it's not being continuously written to. In this case, a new line will be written only once a minute or so. This lessens the chance of losing data if the machine locks up for some reason. Opening and closing does take time and can slow down a loop that needs to run at a certain rate. This loop actually runs in a background process and several other processes send data to it through the queue to be written. The queue can buffer several data streams if needed so you won't lose data if it's busy and you don't have to worry about two processes accessing the Excel sheet at the same time.

Ed

Message Edited by Ed Dickens on 02-18-2006 11:12 AM



Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 10 of 16
(3,563 Views)