Example Code

From Excel to LabVIEW with style

Code and Documents

Attachment

Overview

This VI allows the user to bring in the values and properties of an Excel sheet into LabVIEW.

Description

Using this VI, the user is able to import data and Excel cell properties into LabVIEW. One simple example of this is passing Excel's cell properties directly into a LabVIEW table control and now the user can have access to all of the data values within that specific cell. If you no longer have LabVIEW 2009 installed on your computer with the examples installed, you may run into missing VIs when uploading the Table DropDown.vi. You can replace these VIs with the same VIs of an updated version of LabVIEW for example LabVIEW 2010. In this basic example VI, the VI loads data from Excel's cells A1:C5, obtains the cell's background color from A1 and the validation data from the 5th row only. In LabVIEW, spreadsheet name is passed as a table caption, data from A1:C1 is passed to a LabVIEW table as headers,  A1s background color is passed as a header's background color, and validation data is passed to LabVIEW into a Combo Box.

Update for Table DropDown ver2.vi:

  • Obtains last record from Excel (i.e. reading not fixed 5 rows but as many as spreadsheet holds).
  • Read cells comments and pass them as tip strips.
  • Gets all validation data from spreadsheet and then applies it in LabVIEW to appropriate table cells only (current example limited to column B).

Steps to Implement or Execute Code

  1. Download Table DropDown.vi and Example.xls into same directory
  2. Run VI
  3. Modify the Excel sheet
  4. Run VI again to see changes updated

Requirements

Software

LabVIEW 8.5 and later

Hardware

N/A

Additional Images

Excel Sheet with Data and Also LabVIEW Front Panel of Imported Data

DropDown.png

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors