Example Code

Add Each Row of a Table into a New Excel Worksheet in LabVIEW

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 program indexes the rows from a table control and puts each row into a separate Excel worksheet.

 

Description

While the Excel workbook already needs to exist, the program will create as many worksheets as there are rows in the table. No existing data will be deleted from the workbook. New sheets will just be appended to the beginning. For example, the first three rows will be in Sheet 1, Sheet 2, and Sheet 3, respectively. Any data previously existing in Sheets 1-3 will be moved to Sheets 4-6 in the case of having three rows of data in the table control.

 

Requirements

  • LabVIEW 2012 (or compatible).

 

Steps to Implement or Execute Code

  1. Put a valid excel workbook in the 'Excel Workbook' control.
  2. Fill the table control with the data that you wish to insert.
  3. Run the program, and the new data will be appended.

Additional Information or References 

Main VI Block Diagram

 

capture.JPG

 

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

David R
Systems Engineer
National Instruments

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