NI Home > Community > NI Discussion Forums

LabVIEW

Showing results for 
Search instead for 
Do you mean 
Reply
Member
bobholmgren
Posts: 116
0 Kudos
Accepted Solution

Write to spreadsheet file append

Same problem as this guy here:http://forums.ni.com/t5/LabVIEW/write-to-excel-spreadsheet-in-columns-and-append-to-file-in-a/m-p/10...

 

I'm in labview 7.1.  I am reading in data, and want to append on new columns, whereas the excel spreadsheet function simply appends it onto the bottom of the file. 

 

Is there an easier way to do this, or should I write a VI that reads in a current spreadsheet file, then appends the data to the array as said in that link?

 

Thanks

Member
bobholmgren
Posts: 116
0 Kudos

Re: Write to spreadsheet file append

I also don't see how appending the array would help either, since i will need to have this file have 5 columns, and "Write to Spreadsheet.vi" only supports 2d arrays.

Knight of NI
Dennis_Knutson
Posts: 34,653
0 Kudos

Re: Write to spreadsheet file append

There is no 'Excel Spreadsheet function' unless you are using ActiveX. The Write to Spreadsheet function simply writes a text file and unless you want to switch to using ActiveX and an actual Excel document, then the only way to add columns is by reading in the old file, append the new columns to the array, and write the new.

 

Don't understand your last comment. No matter how many columns you have, it's still a 2D array. How many dimensions did you think you had when you wrote 3 columns?

Member
bobholmgren
Posts: 116
0 Kudos

Re: Write to spreadsheet file append

[ Edited ]

 


Dennis Knutson wrote:

There is no 'Excel Spreadsheet function' unless you are using ActiveX. The Write to Spreadsheet function simply writes a text file and unless you want to switch to using ActiveX and an actual Excel document, then the only way to add columns is by reading in the old file, append the new columns to the array, and write the new.

 

Don't understand your last comment. No matter how many columns you have, it's still a 2D array. How many dimensions did you think you had when you wrote 3 columns?


 

Yeah, I know I'm outputting a text file. 

 

Ah, I gotcha, sorry, new to this. I see now that 3 (or 10 as I'll need) columns is a 2d array, thanks.

Trusted Enthusiast
tbob
Posts: 4,089

Re: Write to spreadsheet file append

If you want to append columns, you would have to read in the spreadsheet data and use Insert Into Array to append to columns.  Just specify column index instead of row index.  Or you could transpose the array, Insert Into Array using row index, then transpose again.  Then write it all back.

 

- tbob

Inventor of the WORM Global
Member
bobholmgren
Posts: 116
0 Kudos

Re: Write to spreadsheet file append

 


tbob wrote:

If you want to append columns, you would have to read in the spreadsheet data and use Insert Into Array to append to columns.  Just specify column index instead of row index.  Or you could transpose the array, Insert Into Array using row index, then transpose again.  Then write it all back.

 


 

That's what I'm working on now, thanks :smileyhappy:

Good to know I'm on the right track

Member
bobholmgren
Posts: 116
0 Kudos

Re: Write to spreadsheet file append

Its more complex than I thought, all the transposing is throwing me off. Along with the fact that Read from Spreadsheet.vi only handles numbers (so my column labels are not happy, keep getting replaced by 0's).

Trusted Enthusiast
tbob
Posts: 4,089

Re: Write to spreadsheet file append

Use the polymorphic selector under the Read From Spreadsheet vi to select String and it will read everything as strings.  Then your labels will remain intact.

 

- tbob

Inventor of the WORM Global
Knight of NI
Dennis_Knutson
Posts: 34,653

Re: Write to spreadsheet file append

Read From Spreadsheet does not only handle numbers. See the little box under the function (yours says 'Double')? Click on the arrow and change the type. You can also right click on it and do a 'Select Type'.

 

This is what is called a polymorphic VI. There are numerous polymorphic functions in LabVIEW.

Member
bobholmgren
Posts: 116
0 Kudos

Re: Write to spreadsheet file append

 


tbob wrote:

Use the polymorphic selector under the Read From Spreadsheet vi to select String and it will read everything as strings.  Then your labels will remain intact.

 


 

 


Dennis Knutson wrote:

Read From Spreadsheet does not only handle numbers. See the little box under the function (yours says 'Double')? Click on the arrow and change the type. You can also right click on it and do a 'Select Type'.

 

This is what is called a polymorphic VI. There are numerous polymorphic functions in LabVIEW.


 

Thanks!