LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Append to start of existingfile using write to spreadsheet.vi?

Solved!
Go to solution
I'm trying to append to the beginning of a file using the write to spreadsheet file with the set file position.vi. I will be collecting numeric data and then calculating timing results when finished collecting. I'd rather not have to pass all the numeric data for the entire length of the test but rather write it on occasion using the write to spreadsheet.vi. When finished append the timing results to the beginning of the file. I can't seem to make this work. Any suggestions? Attached was my first attempt.
Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 1 of 4
(2,456 Views)
Solution
Accepted by topic author GovBob

I've run into this too...the short answer is, no, you can't do that using the "Write to Spreadsheet" VI.  In fact, you can't insert data into the beginning of a file at all without being a little tricky.

 

In my case, I wanted to prepend a header to my file after the data was taken, because (due to customer requirements) the header needed to contain both the start time AND the end time of the data run.  Of course, I didn't know the end time until after the data run was over.  The end time had to be on a separate line from the start time.

 

What I found, after some research on this forum (here), was that it was necessary for me to pre-allocate that line when I wrote my original header (using some dummy data) and then overwrite the dummy data at the end of the run by setting the file mark to "start", then writing a header of identical size but with the correct data in it.  I wasn't able to simply insert it.  

 

The link I included gives some other ideas as well for how you might do this, but you'll probably have to write your own code to do it.

Message Edited by DianeS on 02-02-2010 02:25 PM
0 Kudos
Message 2 of 4
(2,439 Views)

Thanks DianeS! I'm not going crazy then. My requirements are the same as what you described! I was just working on the same idea of preallocating a line and then overwriting it when you posted. I appreciate the feedback.

 

Usually I use the excel report generation toolkit but this time I have to make the file Office version agnostic so I went to the write to spreadsheet.vi. Can't tell you how many posts I reviewed before I posted.

 

Thanks again. 

 

PS Gerd's solution is a pretty good one.

Message Edited by GovBob on 02-02-2010 02:42 PM
Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 3 of 4
(2,432 Views)

You may be going crazy, GovBob, but your post is not a symptom of it.  Smiley Happy

 

Gerd's solution is a pretty good one, I agree.  I found that, for me, it was just quicker to put a dummy line in my header and overwrite that portion of my file, but in some cases that wouldn't be sufficient...so his solution is more all-purpose than mine.

 

Glad I was able to help, and happy file writing!

Message Edited by DianeS on 02-02-2010 03:10 PM
0 Kudos
Message 4 of 4
(2,421 Views)