A straightforward way to get numeric data from Microsoft Excel is to use the VIs that come with the LabVIEW Report Generation Toolkit for Microsoft Office
If you do not have access to these VIs, there are two VIs within LabVIEW that help with reading data from a Microsoft Excel spreadsheet in LabVIEW:Read Delimited Spreadsheet VI
(which replaced the Read From Spreadsheet File VI in LabVIEW 2015 and onward)
If you created your Excel spreadsheet by manually entering the data in (not using LabVIEW and Write Delimited Spreadsheet VI), Read Delimited Spreadsheet VI will not properly interpret your .xls file and will return zeros into your array. In order to get the data into an array in LabVIEW, you will have to save the Excel file as a Tab-delimited text file.
Inputting the new .txt file into the file path node of the Read Delimited Spreadsheet VI will populate your array with the proper data.Note:
If you just need the first column of data, you can wire a True constant to the Transpose?
node and the First Row
output will give you an array with the values of your first column of data.Read From Measurement File Express VI
You may read numeric data in an Excel spreadsheet into LabVIEW using the Read From Measurement File Express VI through the following steps:
1. Double-click on the Express VI to configure it and navigate to the File Format panel and click on the "Read generic text files" checkbox to be able to read a tab-delimited text file (.txt). If you are reading a .lvm file there is no need to select this checkbox:
2. Specify a path to the tab-delimited file by using the "Filename" section in the Configure Read From Measurement File window. You can also do this by wiring the Filename input in the VI with the specified file path.
To save your spreadsheet to a tab-delimited text file, please follow these steps:
- Open your Excel spreadsheet containing simple numeric information.
- Save your Excel spreadsheet as a Tab-delimited text file.
- Click OK. Note that you are only saving numeric data from the active worksheet.
- Click Yes.
- Close your Microsoft Excel document.