Example Code

To create a .csv file and save it into Excel Using 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

.CSV files are very useful because they are relatively small file sizes, can be written easily, and can easily be used in Excel.  Many people save their data to a .csv file, and then wish to transfer it to Excel for more analysis and manipulation. This VI creates an array of strings and saves it as a .csv file, and then imports it into Excel. This utilizes the Report Generation Toolkit.

 

Description

This VI creates an array of string constants and then saves them into a .csv file.  It uses a flat sequence structure to ensure this happens first.  It then sends the reference to the .csv file to a Read from Spreadsheet File.vi, which outputs a 2D array of the elements in the .csv file.  At the same time, this VI creates a new Excel report using the Create Report.vi, from the Report Generation Toolkit.  The reference to this report is sent to an Excel Easy Table.vi, which also takes the 2D array from the Read From Spreadsheet File, and writes the 2D array into the Excel file.  This also takes an input from a control that allows the user to choose where the data is placed in the Excel report.  This is useful if you would like to place the data below another header, or in between other data.  Lastly, it saves this report to a location specified by the user. 

 

Requirements

  • LabVIEW 2012 (or compatible)
  • Report Generation Toolkit

 

Steps to Implement or Execute Code

  1. Type a file path and file name for the Excel file you will create on the front panel.
  2. If you choose, you can also choose the location of your data in the Excel file.  This value defaults to the A1 cell.
  3. Run the VI.
  4. Choose the name of your .csv file and where to save it, in the popup.
  5. Your new Excel report will open automatically.

 

Additional Information or References VI Block Diagram

VI Snippet

insertexcel.png

 

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

 

 

Julian R.
Applications Engineer
National Instruments

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

Comments
Zahkay
Member
Member
on

Hello

I have a  problem which is to export information from labview to excel. I did attach my work down but when i am yielding the output. it is repeatedly giving the same output. I did attached this also. Actually  the vision acquisition detect the QR code and the decoded in the code is stored in the excel. The second problem i am getting is each time i have to open a new file.xls. i can't continue to use the same file. Can some1 helped me please.

database.JPGzad.JPG

micagordon
Member
Member
on

I also want to decode qr code in excel, but I only found the macro for encoding qr code in excel, while didn't find a good macro for decoding qr code, did you find a resolution?

Mo4959
Member
Member
on

Is it possible to export the data from labview to an excel file (sheet 1)  and then run the code again and save the new data in the same excel file but in sheet 2?