Jump to content

How to overwirte data in spreadsheet


Recommended Posts

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 by Ano Ano
Link to comment

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

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.