02-02-2010 01:01 PM
Solved! Go to Solution.
02-02-2010 02:22 PM - edited 02-02-2010 02:25 PM
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.
02-02-2010 02:40 PM - edited 02-02-2010 02:42 PM
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.
02-02-2010 03:10 PM - edited 02-02-2010 03:10 PM
You may be going crazy, GovBob, but your post is not a symptom of it.
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!