Home » excel » Insert rows to excel spreadsheet using LabVIEW

Insert rows to excel spreadsheet using LabVIEW

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a excel spreadsheet which just contains data in the rng A1:A24.

aaa

aaa

aaa

aaa

aaa

..

..

..

I want to add one col of data before this col. So it will have 2 col:

bbb aaa

bbb aaa

bbb aaa

… …

… …

… …

… …

How to do it in LabView?

How to&Answers:

Read/Write spreadsheet file VIs don’t read .xls files. This will work fine for .csv, though. This thread on the NI forum that contains a ton of stuff related to manipulating Excel files in LabVIEW.

Answer:

Follow these steps from NI: Reading Microsoft Excel Numeric Data Into LabVIEW.
Quoting the link:

Use the Read From Measurement File
Express VI:

You may read numeric data
in an Excel spreadsheet into LabVIEW
using the Read From Measurement File
Express VI through a two step process.
First, save your Excel spreadsheet as
a tab delimited text file. Then,
rename the *.txt file as a *.lvm file.
The Read From Measurement File Express
VI can now read the numeric data into
LabVIEW. The following steps will
walk you through the procedure.

  1. Open your Excel spreadsheet containing simple numeric information.
  2. Save your Excel spreadsheet as a tab delimited text file.
  3. Click OK. Note that you are only saving numeric data from the
    active worksheet.
  4. Click Yes.
  5. Close your Microsoft Excel document.
  6. Navigate to the location where you saved your Excel document as a tab
    delimited text file, right-click on
    your filename.txt document, select
    Rename, and rename you file with a
    .lvm extension so that your file now
    appears as filename.lvm.
  7. Read your numeric spreadsheet data into LabVIEW by specifying
    filename.lvm as the File Name in the
    Read From Measurement File Express VI
    configuration window.

Navigate to the location where you
saved your Excel document as a tab
delimited text file, right-click on
your filename.txt document, select
Rename, and rename you file with a
.lvm extension so that your file now
appears as filename.lvm.

Use the Read From Spreadsheet File VI:

The LabVIEW VI ‘Read From Spreadsheet
File.VI’ does not directly read .xls
files, but rather delimited text
files.

If you created your Excel spreadsheet
by manually entering the data in (not
using LabVIEW and the Write to
Spreadsheet File VI) the Read From
Spreadsheet File VI will not properly
interpret your .xls file and will
return zeros into your array. In
order to get this data into an array
in LabVIEW you will have to save the
Excel file as a tab delimited text
file. The procedure for this can be
seen in the example above. Now
inputting this new .txt file into the
file path node of the Read From
Spreadsheet File VI will populate your
array with the proper data. If you
just need the first column of data,
you can wire a True constant to the
Transpose? node, and the First Row
output will give you an array with the
values of your first column of data.