LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write to spreadsheet open

I am using the write to spreadsheet file functionto write one row of data repeated inside a while loop.  when using this function or the inverse fucntion, read from spreadsheet file, do i have to open and/or close the file first?  i have tested it both ways, and I don't really see any differences between having an open/close function to read/write or just having the read/write function.  but i want to make sure I am doing it the right way. 
0 Kudos
Message 1 of 7
(3,573 Views)
The Write to Spreadsheet and Read from Spreadsheet VIs open and close the file.
Andrew Alford
Production Test Engineering Technologist
Sustainable Energy Technologies
www.sustainableenergy.com
Message 2 of 7
(3,567 Views)
The "Write To Spreadsheet File.vi" opens the file internally. You can't wire a file reference, so opening the file before is useless.
In your way of using it, continuously adding data to the file, it might be better to open the file before the while loop and use the "Array To Spreadsheet String" and "Write To Text File" (this one is polymorphic and takes a path or a file reference) in combination inside the loop. After the loop finishes, close the file.
0 Kudos
Message 3 of 7
(3,565 Views)
You know, i was toying between which one to use, the write to spreadsheet or write to text.  In the end, i decided to go with write to spreadsheet because i thought it might be easier to manipulate the row of data, since i also have to read from the file.  what i am doing now is having a case structure that excutes the write to spreadsheet function every hour.  so i guess it will open and close the file once everyhour.  you think that will make my program run noticably less smoothly then if i open and close the file outside the loop?
0 Kudos
Message 4 of 7
(3,559 Views)
If it's only once an hour you won't see any difference in performance. Then I would even recommend using the Spreadsheet file VIs.
If you don't close the file you don't know when the data is actually written to disk because it is stored in a buffer. In case of a program crash or power failure you might lose data (unless you use the Flush File function).
0 Kudos
Message 5 of 7
(3,555 Views)
so does that mean the read/write to spreadsheet file function only opens the spreadsheet internally but doesn't close it?
0 Kudos
Message 6 of 7
(3,552 Views)
Sorry for not being clear.
The spreadsheet file VIs open the file, read/write data, close the file. All internally. So the file will always be updated.
The other way I described, opening a file (and leaving it open) and in the loop use array to spreadsheet and write to file, is more efficient if the data is acquired fast. But here you could lose data in case of a crash because the file remains open as long as the while loop iterates.
0 Kudos
Message 7 of 7
(3,548 Views)