Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
23 ratings:
 2.82 out of 5     Rate this Document

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 Mircosoft Excel spreadsheet into LabVIEW?

Solution:
Use the 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 you 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.  

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 you file with a .lvm extension so that your file now appears as filename.lvm.

Use the Read From Spreadsheet File 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 the Write to Spreadsheet File VI) the 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 the 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. The product page for the Report Generation Toolkit is linked below.

2FC9DK2L: Read From Spreadsheet File Does Not Return All Digits Of Precision

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


Attachments:
ExcelTXT.PNG




Report Date: 08/29/2007
Last Updated: 04/25/2012
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