Showing results for 
Search instead for 
Did you mean: 

Replace different values in different cells

Go to solution



I am new to LabVIEW and work with an instrument that gets it's settings from an Excel file. I need to change those settings in Excel with LabVIEW. The Excel file is formated in .xls (97-2003 version). The PC has Microsoft Office 2013 installed.

I am using LabVIEW 2014 (64-bit).


I want to change the values in 3 different cells in an Excel spreadsheet and save the workbook (not SaveAs).
The main vi is saved in the library in the zip file, it is called 'change 3 values in'.
The excel file is attached separately.
I don't think it matters where those cells are in the Excel worksheet, the Excel memory seems to keep the cell selection of all cells in mind but replaces the value with the last one mentioned in the last sub vi.

1) All cells change to the same value that I define in the third sub vi.
2) Excel asks me for SaveAs and doesn't just save over the existing file.
3) The Excel application doesn't close but I can't seem to figure out why.

Please advice. Help on any of those issues is highly appreciated.

Thank you!

Download All
0 Kudos
Message 1 of 3
Accepted by topic author JR_Sandra

Here is how I would do this.  I would use the Report Generation Toolkit (which is included in LabVIEW 2014).  This Example is a simplified version of your task -- you are given the name of an existing Excel Workbook to modify, the index of the Worksheet to use, the Excel Cell address (in Excel format, i.e. A1, for purposes of illustration), and the Cell Value that you want to insert there.

Replace Excel Cell.png

The first function is New Report, which is a slight misnomer, as we are using it as "Replace Report" by wiring in the name of the existing Report, and specifying that we mean an Excel Report (it will open Excel -- if you don't want the Workbook to be visible, open it Minimized).  We next call Excel Get Worksheet (which isn't necessary if we are using the first Worksheet ...).  We use Excel Easy Table to put the Cell Value into the chosedn Excel Cell.  To do this, we first use Excel Get Excel Location to convert, say, B3, to row/column indices (B3 = 1, 2) and bundle this into a Cluster.  We also need to convert the Cell Value into a 2D Table which we do by passing it through two Build Array functions.  Next we Save Report to File using the original Excel Workbook path, and finally we Dispose Report to turn off Excel.


If you had multiple cells you wanted to update, I would bundle Excel Cell and Cell Value into a cluster, build an array of clusters, then put the Excel Easy Table function into a For loop and do the updates one at a time.


This should work extremely quickly -- the entire process should take a fraction of a second.


Bob Schor

Message 2 of 3

Bob, thank you.


I got it all put together with this helpful advice from you. I worked in the 64bit version of LabVIEW and didn't find the report generation toolkit. IT added this capability for me and now I am able to work with it.


Thanks and have a great day!

0 Kudos
Message 3 of 3