Example Code

Export TAB spaced data to rows and columns in 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

Code and Documents

Attachment

Download All

Overview
This vi copies data to the specified cell in the active Excel sheet.


Description
If Excel is not open Excel will be opened with a new sheet. Data can be text or graphics. Text can be transfered either in call to the vi or from clip board. If you want to copy graphics to Excel you must manually copy the graphics object to clip board before calling the vi. Data must be empty to copy graphics. Data will be copied into one cell or if TAB-spaced into several cells. The target cell can be specified.

The vi uses only ActiveX calls. The example is based on many existing examples out there doing much of the same. The sub vi RC to A1.vi mimics the Excel set Excel location.vi. It converts a row and column number to a type A1 Excel address.


Requirements

Software:

  1. LabVIEW 2012(or compatible)


Steps to Implement or Execute Code

The Copy to Excel.vi would be run as a sub vi

  1. Open Copy data to Excel.llb
  2. Open Copy to Excel.vi
  3. Write something in Data
  4. Enter e4 in A1 address
  5. Run the vi. Excel opens and pastes the Data value in cell E4
  6. Use the Windows Snipping tool and copy some graphics to clip board
  7. Clear Data
  8. Enter g4 in A1 address
  9. Check Dialog box
  10. Run vi. A dialog box opens and asks you if you want to copy data. Hit OK
  11. The graphics is copied into cell G4.
  12. If you have some TAB delimited data copy the data into Data
  13. Check Past Value via clip board
  14. Enter a6 in A1 address
  15. Run the vi. The TAB-spaced data is divided into rows and columns

Additional Information or References
VI Block Diagram

1.png

 **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.