Ano Ano Posted April 29, 2011 Report Share Posted April 29, 2011 (edited) Hello, I have a while loop and I want to write to a file (spreadsheet) continuously. When the stop button is pressed the last data should be saved on the file. The first thing I write on the file is some header info and then the data that is in the loop. The problem is that for each loop the data is appended at the bottom of the old data, where as I want the new data ie from cell C3 to overwrite the old data in cell C3. I can try to set the append to file to "F" but it will delete my file header info. How can I overwrite the data without deleting the header info? Thank you in advance Edited April 29, 2011 by Ano Ano Quote Link to comment
Fab Posted April 29, 2011 Report Share Posted April 29, 2011 Can you post the code you are using? The suggestions we can give you will depend on the approach you are currently taking. I am going to guess that you are using the "Write To Spreadsheet File.vi" in the File I/O palette. I strongly suggest you don't use that inside a while loop. If you open the multiple VIs inside this VI you will see that you are opening and closing the file every time. You can go to the lowest level subVI (Write Spreadsheet String.vi), copy that and use that as a starting point, leaving the opening and closing outside your while loop. You will see that there is a "Set File Position" function that it is set to go to the end of the file when the append to file is set to true. You could do some calculations based on your file size and the size of your last line to set the file position to always be the last line so it gets overwritten every time. Good luck, Fab 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.