LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI to read numeric & alphnumeric data in an Excel file

I'm looking for an example VI that will allow me to select a row from an Excel file based
on a value in the first column then read individual fields into Labview.
Some of the fields are alphanumeric and some are numeric.
After reading the data into Labview I'd like to normalize the data then display it.
I'm using Labview 7.0.
 
Thanks
0 Kudos
Message 1 of 5
(2,894 Views)
The answer to your question really depends on the type of Excel file you are trying to access from LabVIEW. There are two file types of interest that you can use and save in Excel: .xls and .txt. You should be able to accomplish what you want using either file type, but one is a lot more complicated than the other.
 
The easiest file type is the tab delimited spreadsheet (.txt), which is a simple, universal ASCII file that represents a spreadsheet through the use of tabs (column seperators) and carraige returns (row seperators). If you are trying to access this file type, then you can simply read the file into LabVIEW as a normal text file, and then parse through it accordingly using LabVIEW's string functions.
 
The more complicated file type is the Microsoft Office Excel Workbook (.xls), which is Microsoft's proprietary file type that is only compatible with Excel. This means that in order to access this kind of file, you will have to do so using Excel, which can be automated by LabVIEW through ActiveX. Going this route is more involved and requires Excel to be installed on the same machine in which you are using LabVIEW, but it is doable.
 
You should be able to find many examples on both ASCII file I/O and ActiveX by searching our website and these forums. Hope this gets you pointed in the right direction!
 
Kind Regards,
E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(2,868 Views)

Thanks AESulzer, that is helpful. Do you know if it's possible to convert and Excel ".xls" file into a Excel ".txt" file? That would allow me to take the easier route. If not I'll use ActiveX.

Thanks,

Chuck M.

0 Kudos
Message 3 of 5
(2,866 Views)

Open the file in Excel, go to File -> Save As... and in the "save as type" dropdown box, select "Text (Tab delimited) (*.txt)."  This will save the file as a regular text file and you can read it a lot easier in LabVIEW.

If you need the program to work with regular Excel files, you could use ActiveX in your LV program to open the file and save it as a temporary text file so you can read it.  This might be easier than using the ActiveX methods to read the data, but I'm not quite sure as I haven't used ActiveX with Excel yet.

0 Kudos
Message 4 of 5
(2,861 Views)
Thanks!
0 Kudos
Message 5 of 5
(2,852 Views)