LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

'.NET Object to Variant.vi' Cannot Handle 2D Arrays

I am trying to read a range of cells from Excel and convert it to a LabVIEW array of Strings.

 

Unfortuantely, '.NET Object to Variant.vi' cannot handle 2D Arrays, even though you can convert 2D Arrays with 'To .NET Object.vi'. My workaround for this at the moment is to reference each cell in my range and use nested For Loops to recreate the array as a LabVIEW data type.

 

Has anybody found a solution better than this? 

 

Ps. Using LabVIEW 2014 Smiley Happy

0 Kudos
Message 1 of 27
(2,713 Views)

>Unfortuantely, '.NET Object to Variant.vi' cannot handle 2D Arrays

 

Seems to work just fine to me. Do you get an error? Broken wire? Something you don't expect?

 

The result is a variant, you might expect a 2D array. The variant is a 2D array, but you need to use "Variant To Data" to convert it to a 2D array.

Message 2 of 27
(2,661 Views)

I am having an issue here with 2D arrays as well. Here is what I am doing. 

 

aeastet_0-1751456795280.png

This method used to work for active X:

aeastet_1-1751456832557.png

 

What am I messing up here?

 

I do not get anything out of the Value2. I am getting an error 1172 which seems to be the go to for anything you are having issues with in .net. I'm not getting an error out of the Value2 property. I am getting the 1172 out of the .net to variant. Here is the error I am getting:

Error 1172:

Invoke Node in .NET Object to Variant.vi->Open Excel Workbook using .net.vi
<APPEND>
Method Name: <b>.NET:Convert Object To LabVIEW Variant</b>



Tim
GHSP
0 Kudos
Message 3 of 27
(306 Views)

First step would be to wire that Variant to an indicator on the front panel. And then enable "Show Type" in the popup-menu. This will show you what the Variant knows about the internal data type it contains. From there you might have to do a specific conversion to make it work.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 4 of 27
(289 Views)

It shows up as void. So I have to be doing something wrong before this. I am calculating a range (A1:AO414) and that seems to be working correctly. Can you give me another clue? I don't seem to be getting anything from the get range function. Is there a different or better way to get the worksheet ref? I am guessing that is where my problem lies.

 

aeastet_0-1751459472456.png

 

Tim
GHSP
0 Kudos
Message 5 of 27
(284 Views)

Do you need to use .NET?  Here's a good tool - GitHub - dnattinger/read-xlsx-file: A VI that will read the contents of an .xlsx file into LabVIEW w...

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 6 of 27
(268 Views)

Yes I would like to do this in .net. I do not want alternates. I have a whole module that I wrote 15-20 years ago to use with Excel. It is more capable and easier to use than the report generation toollkit. I want to port it to something that is going to be supported moving forward. I keep hearing that Active X is going away. I am just trying to get ahead of the game. Plus it is a fun project to work on. If I can figure out how to get the data out I should be most of the way there. It just isn't working they way I expect and there is nothing anywhere that tells you why. It sound like a few people on here have figured it out. I am just hoping someone will point me in the right direction.

Tim
GHSP
0 Kudos
Message 7 of 27
(265 Views)

I can ask for a single cell and I get the correct response. When I ask for a range I get nothing.

Tim
GHSP
0 Kudos
Message 8 of 27
(252 Views)

@aeastet wrote:

[...] easier to use than the report generation toollkit. [...] I keep hearing that Active X is going away. 


The one I linked doesn't use the RGT or ActiveX.  If that changes anything.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 9 of 27
(225 Views)

@aeastet wrote:

I can ask for a single cell and I get the correct response. When I ask for a range I get nothing.


Not sure if this helps or not, but maybe you're using an invalid range. AI tells me that Excel Interop uses 1-based indexing, so you should start the range from Cells[1, 1] instead of Cells[0, 0]. Just an idea...

0 Kudos
Message 10 of 27
(223 Views)