LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write string to spreadsheet file

I have a code that is writing data to a spreadsheet file in four columns and that works fine. I want to label the columns Time Pressure Temp1 and Temp2. I put these 4 strings into an array but cannot figure out how to write them to the spreadsheet. The write to spreadsheet VI is only allowing for double as an input type. It should be easy so hopefully someone can help me. Thanks in advance.
0 Kudos
Message 1 of 7
(4,566 Views)

Hi,

 

You need to concatenate a header to your data string. Open up the "Save to Spreadsheet" file and take a look at block diagram to see what's going on. See the image below.

 

 It will be even more instructive to look at the block diagram of the "Write Spreadsheet String.vi" as well to see how NI does the actually saving of the of data string.  Hope this helps.

 

Cheers,

 

--Russ

 

 

Message Edited by Russ Evans on 10-08-2008 05:00 PM
Message 2 of 7
(4,559 Views)
Instead of modifying a stock VI, which is not necessary in this case, and would affect all future code, as well as break the VI in case LabVIEW gets reinstalled, simply call the Write to Spreadsheet File twice. The first time you call it you write out your header, which would be an array of strings. The second time you write out your data, which would be an array of numbers. In this second call you set the "append" input to True. The Write to Spreadsheet File is polymorphic, so you can change the type of data it acts upon.
Message 3 of 7
(4,549 Views)

I'm sorry I wasn't clear, I didn't mean to modify the stock vi but rather simply to take a look at what "magic" is going on in the stock vi and by example create a similar vi that suites your needs (if necessary). I think once you take a look at what is really happening in the Save to Spreadsheet.vi (and similar stock vi's) you will see many possibilities for creating your own vi's.

 

cheers,

 

--Russ

0 Kudos
Message 4 of 7
(4,546 Views)

I do the approach that Saverio mentionned.  Much easier and calling the Write to Spreadsheet File twice is not considered a sin..

Keep It Simple..

0 Kudos
Message 5 of 7
(4,528 Views)
I do have it set up as writing to the spreadsheet file twice, once for the headers outside my while loop(time temp etc) then once for the data. However, the write to spreadsheet VI only accepts type double and I get a dotted line when trying to connect my array of strings to it. I will try messing around with it more and using the array to spreadsheet string, but because it looks like only a double type will be accepted, will I have to go into write_to_spreadsheet.vi and change the property node so that it accepts strings instead? Is there a work-around? Sorry in advance, I can't try any of your suggestions until tomorrow.
0 Kudos
Message 6 of 7
(4,507 Views)

What version of LabVIEW are you using?  I think it was one of the versions in the 8's that the function became polymorphic and allowed strings to be written to it.

 

Instead of using a Write to Spreadsheet VI for the first write, just make up the string of headers and use a write to text file function first.

0 Kudos
Message 7 of 7
(4,503 Views)