How to Write to Excel in Labview

Written by aalhad deshmukh
  • Share
  • Tweet
  • Share
  • Email

Labview is software that is often used for acquiring large amounts of data. This data must be stored in a readable and convenient format for future analysis and archiving. Excel provides such features to save data for users. A step-by-step procedure to save data from Labview into an Excel worksheet can be determined by relating the programming steps to the manual steps that are required to manually save data in an Excel worksheet.

Skill level:
Moderate

Other People Are Reading

Things you need

  • Computer with Windows XP or Windows 7
  • Labview 8 Software Development System
  • Excel software

Show MoreHide

Instructions

  1. 1

    Launch Excel from Labview. Drag and drop the "Automation Refnum" component in the Labview "Front Panel" using the "Controls" palette. Drag and drop the following components in the Labview "Diagram" using the "Function" palette:

    1. Open Automation

    2. Property node

    Right-click on the "Automation Refnum," point on "Select ActiveX Class" and select "Excel._Application." In the "Diagram Window," connect the "Automation Refnum" to the "Open Automation" block. Connect the output "Reference" from the "Automation Open" to the "Reference IN" on the property block (this is the reference to the Excel application that is to be used on multiple blocks in this code). Select "Visible property" and set it to "True."

  2. 2

    Write code to create a new "WorkBook" using the Excel application reference. Drag and drop the following components in the Labview "Diagram" using the "Function" palette:

    1. One more Property node (call it A)

    2. One Invoke node (call it B)

    Connect the Excel reference to property node "A" and select the property "WorkBooks." Connect the output of the "Workbooks" property to the "Reference IN" for the invoke node "B." Select the method "Add." The output of "Add" will provide a reference to the new "WorkBook."

  3. 3

    Write code to open a new "WorkSheet" using the "WorkBook" reference. Drag and drop the following components in the Labview "Diagram" using the "Function" palette:

    1. One more Property node (call it C)

    2. One more Invoke node (call it D)

    3. Variant to Data block

    Connect the "WorkBook" reference to the "Reference IN" of the next property node "C." Select property "Sheets." Connect the output of the "Sheets" property to the "Reference IN" for the next invoke node "D." Select method "Add." The output of "Add" is a variant. Convert the variant into an "Excel._Worksheet" reference by using the block "Variant To Data."

  4. 4

    Write code to add data to cells using the "WorkSheet" reference. Drag and drop the following components in the Labview "Diagram" using the "Function" palette:

    1. One more Property node (call it E)

    2. One more Invoke node (call it F)

    3. String constant

    Connect the "WorkSheet" reference to the "Reference IN" for the invoke node "F." Select method "Range." This will automatically show "Cell1" and "Cell2" inputs on the invoke node "F." Connect the output of the "Range" method to the "Reference IN" for the property node "E."

    Enter the value "A1" in the "String constant." This means that the value is to be written to the cell "A1." Select property "Value2" on property node "E." Drag a "string control" from the "Controls" palette on the "Front Panel" and enter any string value, such as "Name." In "Diagram" view, connect this to the "Value2 property" input.

  5. 5

    Write code to save and close Excel. Drag and drop the following components in the Labview "Diagram" using the "Function" palette:

    1. Two more Invoke nodes (call them G and H)

    2. Automation Close block

    Connect the "WorkBook" reference from Step 3 to the "Reference IN" of invoke node "G." Select method "Close." Connect "Reference Out" from invoke node "G" to "Reference IN" of the "Automation Close" block. Connect the Excel reference from Step 1 to the "Reference IN" of invoke node "H." Select method "Quit." Run the Labview program by clicking the "Run" button on the "Front Panel" of the program.

Tips and warnings

  • Run through a basic tutorial of Labview programming to understand how to navigate in that programming environment.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the eHow.co.uk site, you consent to the use of cookies. For more information, please see our Cookie policy.