LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to spreadsheet without prompting each time through a loop

Solved!
Go to solution

Attach your code.

 

Again, as we said, "write to spreadsheet file" has nothing to do with excel file format. If you look at the file in notepad, does the data exist OK?

0 Kudos
Message 11 of 34
(1,957 Views)

Yes of course that works. I understand that write to spreadsheet it a text file. I was told elsewhere weeks ago from others that you could write to spreadsheet and choose a .xls file and the text would open nicely into excel even though its a text file. Is that wrong? Is the better way to send to like a notepad and copy it over into excel?

 

Edit: Also is there an easy way to reset the data? I know you can right click the data and go to data operations and reinitilaize to default value. My issue with the timestamp though is that it goes to 0 but if I run a new trial the time stamp does not restart at time 0 it picks back up from the previous readings. There has to be an easy way to reset it to 0 but I am missing it

0 Kudos
Message 12 of 34
(1,953 Views)

As  has stated the write to spreadsheet vi does not exactly make XLS or XLSX files.

 

It makes (default) TAB delimited text files.

 

You can change the delimiter looking back at your code it looks like you have an empty text string wired to the delimiter input.

 

Remove that and go with the default TAB or use a comma.

 

Give the file name an XLS extention if using TAB and a CSV extenetion if using a comma

 

Then Excel should have no problem opening it.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 13 of 34
(1,951 Views)

I recommend AGAINST giving it an .xls extension.  .xls implies it is an Excel file, which it is not, and just adds to the confusion as to what type of file you have.

 

"Hmm, this file is called myfile.xls.  Is this an Excel file or is this a text file?  I don't know."

 

Calling a text file. xls is just a hack to get it to open in Excel because generally Excel is smart enough to know how to import it.  You are better off calling it .csv, or .txt, and using right click open with Excel to open Excel and import it.  Then you don't have the confusion as to exactly what the file format is at the moment that is sitting on your hard drive.

 

The confusion gets worse if you have a text version .xls, open it in Excel which imports it, then save it, which will cause it to be saved as a true .xls file.  Now if you try to use Read from Spreadsheete file, or append more data to it with Write to Spreadsheet file, you'll just wind up with a garbled mess.

0 Kudos
Message 14 of 34
(1,947 Views)

@RTSLVU wrote:

Remove that and go with the default TAB or use a comma.


Just a side comment: An empty delimiter will default to a tab, something I am trying to change. 😄

0 Kudos
Message 15 of 34
(1,946 Views)

Ah that helped. I had teh comma delimiter in previous versions but it didn't work, giving it the .csv extention was the issue there. Thanks. My final issue is with current readings. It has the part in there to change from voltage to current so that is not the issue but my issue is that my current is in the micro amp range and the data spits it out as 0. Is there a way to have it spit it out as e^-whatever the value is?

0 Kudos
Message 16 of 34
(1,944 Views)

You'd be better off converting the data to a string array using the appropriate format specifer for each column of your data.  Then using the string version of the Write to Spreadsheet file to write it out.

0 Kudos
Message 17 of 34
(1,940 Views)

@Ravens Fan wrote:

I recommend AGAINST giving it an .xls extension.  .xls implies it is an Excel file, which it is not, and just adds to the confusion as to what type of file you have.

 

"Hmm, this file is called myfile.xls.  Is this an Excel file or is this a text file?  I don't know."

 

Calling a text file. xls is just a hack to get it to open in Excel because generally Excel is smart enough to know how to import it.  You are better off calling it .csv, or .txt, and using right click open with Excel to open Excel and import it.  Then you don't have the confusion as to exactly what the file format is at the moment that is sitting on your hard drive.

 

The confusion gets worse if you have a text version .xls, open it in Excel which imports it, then save it, which will cause it to be saved as a true .xls file.  Now if you try to use Read from Spreadsheete file, or append more data to it with Write to Spreadsheet file, you'll just wind up with a garbled mess.


 

While I understand your point here I have recently been doing just the oppisite. For ages I would put all my data files in  CSV format. Until recent MS Office have quit opening CSV files by default. Now when opening a CSV it steps through an "Import Wizzard", this confuses my managers and they are always asking me what is wrong with my data files.

 

So to eliminate this "confusion" I have been makeing TAB delimited files and putting an XLS extention on them.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 18 of 34
(1,935 Views)

@Ravens Fan wrote:

You'd be better off converting the data to a string array using the appropriate format specifer for each column of your data.  Then using the string version of the Write to Spreadsheet file to write it out.


I have not made it to the formatting yet. I am having issues converting to the string array. I guess I am more confused where the positioning should be. I assume it has to be done in the loop, but it doesnt seem like the wirings of the format into string match everything else going on in the loop. Do you have any suggestions or help on how the data gets converted in a string array?

 

Not sure where teh string to spreadsheet is supposed to go either is it supposed to go into the write to spreadsheet like I have? Sorry if these questions are supposed to be easy and I am insulting your intelligence. I am not that crisp with LabView

0 Kudos
Message 19 of 34
(1,924 Views)

NO,NO,NO.

 

Just wire the 2D numeric array to the Write to Spreadsheet File. The Array to Spreadsheet String would be used only if you used a low level write file function instead of the Write To Spreadsheet. Turn on Context Help and read it when you hover over the Write to Spreadsheet. Read about the format string.

0 Kudos
Message 20 of 34
(1,921 Views)