Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
32 ratings:
 3.03 out of 5   

Reading Microsoft Excel Numeric Data Into LabVIEW



Primary Software: LabVIEW Development Systems>>LabVIEW Professional Development System
Primary Software Version: 8.2.1
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:
How can I read numeric data from my Microsoft Excel spreadsheet into LabVIEW?

Solution:
There are two VIs that help with reading from a Microsoft Excel spreadsheet in LabVIEW: Read From Measurement File Express VI and Read From Spreadsheet File.vi (replaced with Read Delimited Spreadsheet.vi in LabVIEW 2015 and onward).

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 a two step process.  First, save your Excel spreadsheet as a tab delimited text file.  Then, rename the *.txt file as a *.lvm file.  The Read From Measurement File Express VI can now read the numeric data into LabVIEW.  The following steps will walk you through the procedure.
  1. Open your Excel spreadsheet containing simple numeric information.
  2. Save your Excel spreadsheet as a tab delimited text file.

  3. Click OK.  Note that you are only saving numeric data from the active worksheet.
  4. Click Yes.
  5. Close your Microsoft Excel document.
  6. Navigate to the location where you saved your Excel document as a tab delimited text file, right-click on your filename.txt document, select Rename, and rename your file with a .lvm extension so that your file now appears as filename.lvm.
  7. Read your numeric spreadsheet data into LabVIEW by specifying filename.lvm as the File Name in the Read From Measurement File Express VI configuration window.

Read From Spreadsheet File VI (Read Delimited Spreadsheet VI):

The LabVIEW VI Read From Spreadsheet File.vi does not directly read .xls files, but rather delimited text files.

If you created your Excel spreadsheet by manually entering the data in (not using LabVIEW and Write to Spreadsheet File.vi), Read From Spreadsheet File.vi will not properly interpret your .xls file and will return zeros into your array.  In order to get this data into an array in LabVIEW you will have to save the Excel file as a tab delimited text file. The procedure for this can be seen in the example above.  Now inputting this new .txt file into the file path node of Read From Spreadsheet File.vi will populate your array with the proper data. 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.

Note: Microsoft Word and Microsoft Excel are powerful standard software packages for creating reports. Because of their popularity, some LabVIEW users programmed LabVIEW ActiveX applications to dynamically control these document packages for generating reports from LabVIEW. The complexity of the ActiveX interface of those packages, however, makes the development of custom applications difficult. With the LabVIEW Report Generation Toolkit for Microsoft Office, you no longer have to learn the complex object models of Microsoft Word and Excel to generate a report. The Report Generation Toolkit is a library of flexible, easy-to-use VIs for programmatically creating and editing Microsoft Word and Excel reports from LabVIEW.



Related Links:
KnowledgeBase: 39RGHMZH: How do I Read or Write to Named Cells or Named Ranges in Excel Using the LabVIEW Report Generation Toolkit?
KnowledgeBase: 2FC9DK2L: Read From Spreadsheet File Does Not Return All Digits Of Precision
LabVIEW Report Generation Toolkit for Microsoft Office
LabVIEW 2011 Help: Read From Spreadsheet File VI
KnowledgeBase: 2FC9DK2L: Read From Spreadsheet File Does Not Return All Digits of Precision

Attachments:
ExcelTXT.PNG




Report Date: 08/29/2007
Last Updated: 08/28/2017
Document ID: 4CSI7PQ7

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit