LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to spreadsheet problems

I am trying to use the following program to write data to a spreadsheet. It is meant to monitor and record information about various parts of a sputtering machine. However, when run, it gives me a sheet with only the headers on it, and often asks several times in the same run whether I would like to write over the old file. I would like it to just append to the file, rather than rewriting it every time, as that would make the program useless. Why does it not write the data to the file?

Note: everywhere there is a blank node in the file, there is in the real program a string of data from another source that is read at the same time this program is run. The file is provided by a front panel control that I forgot to include in the file.
----------------------------------------------------------------------------------------------------------------------------------------------------
I've got a sneaking suspicion that Jesus might have been made of bread. Why else did they have to put him in a warm cave and wait three days for him to rise?

Damnant quadnon intelligunt - They condemn what they do not understand.
0 Kudos
Message 1 of 3
(2,747 Views)
I'm not too familiar with the format into file VI but it looks like it cannot append.  I would use a format into string or concatenate string (like you did with your header) to generate the line to be written and then use write to file again but with pos mode set to end.
LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 2 of 3
(2,739 Views)

You've made some pretty obvious mistakes. First, your Open/Create/Replace File is set to "create or replace". The function means exactly what it says. If the file doesn't exist, create it and if it does exist, replace it. You don't have anything wire to the advisory dialog so every time it runs, you'll get a message asking you if you really do want to replace it. Second, you are using the Format Into File function. As the help mentions, you cannot use this to append data to a file. And, you have no data wired to it anyway so all you get is a header.

You don't have to use the Open/Create/Replace function each and every time. At the very beginning of the program, you can create the file once and then just use the Write File to append data. Use the Close File at the very end. You can also make things simpler by using the Write To Spreadsheet File function. It has an input for Append. You can use the Write File at the very beginning to write a header once and then call Write to spreadsheet and pass an array of data. It will do the formatting for you (adding tabs, etc.).

0 Kudos
Message 3 of 3
(2,736 Views)