To download NI software, including the products shown below, visit ni.com/downloads.
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.
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?
LabVIEW 2012 (or compatible)
Steps to Implement or Execute Code
Additional Information or References
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.