LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

write cluster to spreadsheet programatically

Hi,

 

I have a large program where I am acquiring user input via nested strict type def's.  The idea is that I can change/add fields in a centrally located control and have the rest of the program automatically adapt.  One of the functions is to log these fields to a spreadsheet.

 

I am having trouble finding a programatic way to log the cluster to a spreadsheet.  I have attempted multiple methods including some of the functions within openg as well as using variants.

 

Currently I am unpacking the clusters, converting all data types to strings, and building them into an array to send to 'Write Spreadsheet to File.vi'.  It's apparent that this method is laregly dependant upon which fields are in the cluster and is by no means 'programatic'.

 

TIA,

Chris

0 Kudos
Message 1 of 8
(3,276 Views)

One method I have contemplated is converting the cluster to an array and using a for loop to build a string to log to the spreadsheet.  The problem I run into here, is finding a vi that tells me what data type the field is so that I can choose which data conversion to use.  

0 Kudos
Message 2 of 8
(3,273 Views)

One way to do this is to use property nodes.

 

code.png

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 3 of 8
(3,261 Views)

Adnan,

 

Thanks I will give this a shot.

 

Chris

0 Kudos
Message 4 of 8
(3,256 Views)

No, it returns values. I understood your issue; you should try what I suggested.

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 5 of 8
(3,251 Views)

Yes, I see that, sorry.  I missed the indexing of the loop and sub function.

 

You are actually a bit too fast on your response, I noticed this right after I posted and then changed my post.   🙂

 

Thanks again!

0 Kudos
Message 6 of 8
(3,247 Views)

OK, so the problem I am having now is that this appears to work with a single cluster.  Although when having nested clusters it produces a class name of 'cluster' for all of them since it is not going inside each cluster.   The obvious solution for this would seem to be using a nested for loop to go another level deeper, although this is not an option, it will not index again.

 

Thoughts?

0 Kudos
Message 7 of 8
(3,240 Views)

I could create a property node for each of the nested clusters within the original cluster, although with this I would lose the ability to change fields in the cluster and not have to make other changes within the program.

 

Chris

0 Kudos
Message 8 of 8
(3,237 Views)