LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading excel file

how come i can read some excel files just fine and others come out as garbage when using "read data from spreadsheet" vi... in fact, data just typed in by hand doesn't get read... but there is a program in our lab that outputs data to an excel file and it reads that just fine... anyone have any ideas? thanx!
0 Kudos
Message 1 of 5
(3,642 Views)
A "spreadsheet file" is not an Excel file. The "write to spreadsheet file.vi" creates a tab separated ASCII formatted table by default.

Your application does not write an Excel file, just a spreadsheet file with an *.xls extension. This extension fools windows explorer to open it in Excel and Excel is smart enough to detect that it is not an Excel file and opens it still in a reasonable way. See my comment in the Earlier post.

True Excel files have a proprietary format devised by Microsoft. If you want to read and write to genuine Excel files, you need the Office toolkit or use the technique outlined by M
ichael Munroe in the above mentioned thread.
Message 2 of 5
(3,642 Views)
actually... i think it might just be a real excel file cuz the guy who worked there before me really knew what he was doing... i can't be too positive though, i just know that it opens in excel and the formatting is perfect and i don't have to "export" anything... is there a way to tell the difference between a real excel file and a fake one? i was able to figure out how to write to an excel file using some of the examples provided in labview... but reading from one hasn't been as easy... i had to output to an excel file... not only that, but it had to append to the excel file... i came up with a roundabout way of doing by outputting all the data to a text file.. then reading the text file using "read from spreadsheet file" vi and then taking that data an
d overwriting the excel file... so basically i update two files at once... my boss wanted to output to an excel file so go figure... did that make sense? is that a bad way of doing it?

thank you
Christina
0 Kudos
Message 3 of 5
(3,642 Views)
In any case, read/write to/from spreadsheet file does not work with native excel files. How to tell the difference? An empty excel file is already ~14kb in size, so if your files are smaller they are most likely not excel files.

Open some of your files using notepad. A real excel file will have lots of strange characters and you should not easily see the actual table data. A fake excel file will nicely show the table data, even in notepad.

I think writing your data directly into a proprietary microsoft format is overrated unless you need some of the fancy formatting (Different fonts, sizes, merged cells, etc.). Excel can import vitually any reasonable spreadsheet-like text written by LabVIEW. I sometimes write spreadsheet data as comma-
delimited ASCII table and name the file "*.csv". csv files also open in excel and there is no confusion about the format.
Message 4 of 5
(3,642 Views)
thanx, you were right... it was a text file...
0 Kudos
Message 5 of 5
(3,642 Views)