Example Code

Reading Excel Data Programmatically Using the Report Generation Toolkit

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW Report Generation Toolkit
  • LabVIEW

Code and Documents

Attachment

Overview:

This simple program is a demonstration of how to use the LabVIEW Report Generation Toolkit to read data from Excel programmatically.

 

 

Description:

The first part of the program is a File Dialog Express.vi which asks the user to select the Excel file that he wants to read (use the read_excel_values.xls in the attached zip file).  Then the correct worksheet is selected with the "Excel Get Worksheet.vi".  This is done with the worksheet index number for the first two sheets and by worksheet name in the last.  After each "Excel Get Worksheet.vi" there is an "Excel Get Data.vi" which will grab the data corresponding to the start and end position (or location depending on the type of array) passed into the SubVI.  For the 2-D array data types you must give start and end points for the array.  For non-arrays you only need to give the location of the cell.

 

 

Requirements:

LabVIEW 2012 (or compatible)

LabVIEW Report Generation Toolkit 2012 for Microsoft Office (or compatible)

 

 

Steps to Implement or Execute Code:

  1. Download and Unzip the attached folder "Read Excel Programmatically.zip"
  2. Open "Read Excel Values.vi"
  3. Run the VI and a dialogue will appear
  4. Browse to the excel file you'd like to use, and continue

 

Additional Information or References:

 

Block Diagram

 BD.PNG

 

 

**This document has been updated to meet the current required format for the NI Code Exchange. **

Justin Parker
National Instruments
Product Support Engineer

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

Comments
NI Employee
on

Great code!  Thanks for sharing this!

Todd S.
LabVIEW Community Manager
National Instruments
Member
Member
on

Tks too!!

Active Participant
Active Participant
on

got me started quickly with reading Excel files. Thanks!

Member
Member
on

Hi ! 

I was reading the discussion and i didn't find an efficient solution to read a muti-sheets .xlsx file in labview, I want to load the content of each worksheet and get a 2D data array.

Does someone have any idea about how to solve this please?

Thank you.

Member
Member
on

Easy Solutionread excel xlsx.png

Member
Member
on

Hello everyone, I hope you guyz are doing well. I need your help, I want to search some integer values which maybe 100 rows and store in one array for further uses. I am confused which one algorithm is working faster in this scenario. If any recommendation or someone already did that type of searching then please help in this problem. Thanks to all. 


@Justin_P wrote:

Overview:

This simple program is a demonstration of how to use the LabVIEW Report Generation Toolkit to read data from Excel programmatically.

 

 

Description:

The first part of the program is a File Dialog Express.vi which asks the user to select the Excel file that he wants to read (use the read_excel_values.xls in the attached zip file).  Then the correct worksheet is selected with the "Excel Get Worksheet.vi".  This is done with the worksheet index number for the first two sheets and by worksheet name in the last.  After each "Excel Get Worksheet.vi" there is an "Excel Get Data.vi" which will grab the data corresponding to the start and end position (or location depending on the type of array) passed into the SubVI.  For the 2-D array data types you must give start and end points for the array.  For non-arrays you only need to give the location of the cell.

 

 

Requirements:

LabVIEW 2012 (or compatible)

LabVIEW Report Generation Toolkit 2012 for Microsoft Office (or compatible)

 

 

Steps to Implement or Execute Code:

  1. Download and Unzip the attached folder "Read Excel Programmatically.zip"
  2. Open "Read Excel Values.vi"
  3. Run the VI and a dialogue will appear
  4. Browse to the excel file you'd like to use, and continue

 

Additional Information or References:

 

Block Diagram

 BD.PNG

 

 

**This document has been updated to meet the current required format for the NI Code Exchange. **