Example Code

Append Data to an Excel Document Every Iteration Using 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

Description

Overview

This example generates a 2D array of random data and then writes it to an Excel document using the Report Generation Toolkit; this example writes multiple times to the same Excel document.

 

 

Description

When writing to Excel, the Report Generation Toolkit  usually waits for all of the data to arrive before performing a write. In some applications it is more appropriate to write to a spreadsheet multiple times rather then waiting for all the data to arrive. This example demonstrates how to write to an Excel spreadsheet multiple times in the same VI (via a while loop). This example also prevents data from being overwritten/erased by successive writes.

The VI checks if the  document already exists. If not, it creates it and uses the Save Report to File VI. If it does exist, it saves using the Dispose Report VI with the Save Changes input set to True. Save Report to File VI is only used with new files.

 

Also note that if the file exists, the report path is wired to the New Report VI Template input. Check out the related KnowledgeBase 2TE86ETL: Can I Add New Data to an Existing Excel File Without Erasing Old Data?

 

 

Requirements

LabVIEW 2012 (or compatible)

Report Generation Toolkit (now included with LabVIEW Professional)

 

 

 

Steps to Implement or Execute Code

  1. Download and Save VI
  2. View Block Diagram
  3. Click Run button. Note that the Excel file will be saved in the same location where you saved the VI

 

Additional Information or References

 

Appending Data to Excel

 

 

 

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

Jeff | LabVIEW Software Engineer

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

Comments
Todd S.
NI Employee (retired)
on

Great example and great documentation and linking.  It looks like the image is broken on my browser, do you mind reposting a smaller version of the image?

Todd S.
LabVIEW Community Manager
National Instruments
JeffL
NI Employee (retired)
on

It should be fixed now!

Jeff | LabVIEW Software Engineer
metoo
Member
Member
on

could you save for 8.5 ?

syrpimp
Member
Member
on

Very Good...



Thank you & Best regards
syrpimp

=======================================================
“You must continue to gain expertise, but avoid thinking like an expert." -Denis Waitley
GYALI
Member
Member
on

plz describe step by step