LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

'To .NET Object.vi' can't handle a 2D array of variants

It gives error 1199 when fed a 2D array of variants. Why is this a problem for me? Because I tried to create a .NET analog of 'Write table to Excel.vi'. Why? Because In Excel 2016 it looks like Microsoft finally deprecated ActiveX automation used fro communication with Excel by both the shipped 'Write table to Excel.vi' example and Report Generation Toolkit.

 

When using ActiveX the Value2 property of Range object had a type Variant as seen from Labview. It could accept a 2D array of any type, including an array of variants (which, for example, could have been returned as a result of an SQL query from a DB). It was very convenient to be able to export such data as is, i.e. as a 2D array of variants, directly into Excel.

 

When using .Net interface though, the Range.Value2 property is of type '.Net Object'. So one has to use the 'To .NET Object' vi to convert. It works with 2D arrays of both strings and, say, doubles. They get exported to Excel just fine. But it can't handle a 2D array ov variants!

0 Kudos
Message 1 of 7
(3,807 Views)

OK, so ActiveX still works in Excel 2016. But it is older than .NET and they can still deprecate it in the next version. So, experience on how to communicate with Excel via .NET can become very valuable.

0 Kudos
Message 2 of 7
(3,774 Views)

Hi,

I am looking to the same solution. It seems that .NET Obj to variant for 2DArray produces error:


Error 1172 occurred at Invoke Node in .NET Object To Variant.vi->ExcelRead2DString.vi->FunctionTest.vi

Possible reason(s):

LabVIEW:  A .NET exception occurred in an external assembly. For information about correcting this error, copy the following exception (in bold), and search the Microsoft Developer Network (MSDN) Web site or the Web for a possible explanation.

Method Name: .NET:Convert Object To LabVIEW Variant

Anyone have the solution yet?

Thanks,

 

Rajamodol

0 Kudos
Message 3 of 7
(3,544 Views)

.NET Obj to variant for 2DArray is not handled, unfortunately, even though 2DArray to .NET Obj is handled.

My current workaround for this is to use nested for loops to get the .NET Obj data type for each cell and then build an array using the same indexes.

 

If somebody has found a solution to this, I would really appreciate if you could share it.

 

0 Kudos
Message 4 of 7
(3,038 Views)

Thanks for sharing your workaround!

 

Since this thread is from a year ago, I would recommend posting your question in a new thread to get more visibility. You can reference this forum in the new post.

Adena L.
Technical Support Engineer
National Instruments
0 Kudos
Message 5 of 7
(3,025 Views)

Hi everyone,

Bugsy26_0-1689758351046.png

 

The above method is the only one working ok found by me so far. But for large files it takes too much to load them. I fell asleep near the computer for files with 10 000 rows ...

 

The next one, using Value2 property is still not working.

Bugsy26_0-1689758202612.png

 

Has anyone else found a workaround for this matter?

 

Thanks,
Daniel  

0 Kudos
Message 6 of 7
(675 Views)

... delete

0 Kudos
Message 7 of 7
(674 Views)