LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

i want to read and use some informations from a excel file

To test a graphic, i need to take a lot of numbers  in a excel file...
 
but i dont know how to open and read this file but i dont know how...
 
thx for your help...
 
 
0 Kudos
Message 1 of 3
(3,106 Views)

Hello,

You can open, read, and even write excel files (if you write a file with extension .xls, windows will interpret it as an excel file be default) using the File I/O VIs in LabVIEW.  To extract the data, all you really need to realize is that spreadsheets programs like excel store data with the following basic rules:

1. the entire spreadsheet is really just a large string - to read them, you just have to know the data you read is stored based on rules 2 and 3; to write them you just have to conform to rules 2 and 3.

2. cells in a given row are delimited by tabs (usually by default) and sometimes commas (but usually only if you set this specifically in the spreadsheet program)

3. rows are delimited by end of line characters, which will usually be one carriage return and one linefeed character in that order on windows.

In fact, for writing spreadsheet strings (which can be opened in excel) from LabVIEW, check out the Array to Spreadsheet String and Spreadsheet String to Array functions in the String Palette.  That is, if you imagine the excel spreadsheet as a 2D array, those functions will essentially convert between the large string, and a 2D array in LabVIEW containing the values you would see in excel's corresponding cells.

I have attached a program that will use the array to spreadsheet string function to write an excel file containing those values - it will be named test.xls and should be on your C: drive directly.  A good exercise to get started would be to write a VI using similar (some inverse) functions to read that string, and convert it back to an array.

I hope this helps!

Best Regards,

JLS

Best,
JLS
Sixclear
0 Kudos
Message 2 of 3
(3,084 Views)
That works well for writing files.  Excel will take any tab-delimited file and convert it to MicroSoft's format.  That format is not easily read by labview.  I.e. if you wanted to read an excel file with the Read from Binary File, all you would get is gibberish.  NI does offer a suite of MS Office tools, but it is not in the base package.

You could save the excel file as a tab-delimited text file, first.  Then you should be able to read the file fairly easily in Labview.
0 Kudos
Message 3 of 3
(3,080 Views)