From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read/write excel

Solved!
Go to solution

Brzhou123_0-1592104375111.png

Hi Sir, 

 

I want to read the dicated row of column of of worksheet, but till here, i do not know how to move forward.

I read some samples, but seems it is complicated, too many steps.

 

Is there a faster way ?

Thanks.

Keep moving
0 Kudos
Message 1 of 4
(2,158 Views)

Hi Brzhou123,

 

The first thing you want to do is use the "Open" output from the Workbooks invoke node.  This contains the reference to the workbook that you have opened and you can use it to obtain a reference to the Worksheets collection.

 

You can then select the worksheet you want by name.  Because this returns a variant, it must be converted to a worksheet reference before use.  The only way I know to read data from the worksheet is to define a Range and read its Value property.  If the Range consists of a single cell, the returned variant can be converted in to whatever data type is required.  If the Range consists of multiple cells, LabVIEW shows the returned variant as Array(Non Displayable) and I'm not sure how to deal with this.

 

Finally, don't forget to close the workbook and all the references.

 

I've attached an example VI to show you what I'm talking about (LV2015 32-bit).

 

PsyenceFact

0 Kudos
Message 2 of 4
(2,099 Views)

Hi Sir,

 

Thanks for your details and sample.

I am some questions to understand this kind of property call much better:

 

1. I know this is a active X call, where to get below icon ?

 

Brzhou123_0-1592148069120.png

 

 

Or i should put the property node first, and select the application ?

Thanks.

Keep moving
0 Kudos
Message 3 of 4
(2,092 Views)
Solution
Accepted by topic author Brzhou123

Perhaps the most simple is to place the Automation Open on the diagram, right-click on the Automation Refnum terminal and Create Constant.  You can then right-click on the constant and Select ActiveX Class.

 

If you have the Report Generation Toolkit installed, you can create a new Excel report then use Excel Get ActiveX References.vi from the Report Generation - Excel Specific - Excel Advanced palette.  One of the outputs of this VI is the Excel._Application reference.

 

PsyenceFact

Message 4 of 4
(2,078 Views)