Showing results for 
Search instead for 
Did you mean: 

Reading from an Excel to an array for use in the program

Go to solution

I am very new at LabView.  I want to be able to read some data from an Excel file and store it into an array for use in the LabView program.  The problem I have is that it appears that I can only write the data into an indicator array, but I need it in a control array.  The data has to be read and stored as it would take too much time to read and use the data in real time.  Is there a way to solve this? 

0 Kudos
Message 1 of 16

Hi Gizmo,


Can you share what you have done so far ?

Save it for LabVIEW 2020 (or prior) before sending it to us.

0 Kudos
Message 2 of 16

Look into the Report Generation Toolkit. To get to that, go to the Block Diagram, right-click on any white space, then go under Programming - Report Generation - Excel Specific.


Also, upload your VI and make sure you use Save to Previous Version and select 18.0. You should be pretty safe down converting it for others to view and add their suggestions.




0 Kudos
Message 3 of 16

A control is a data source and an indicator is a data sink, both are just front panel elements. In your case, the file is the data source, so why would you need it as a control? Do you want to manually modify the data later?


If you need the data for computations, just branch the wire going to the indicator at connect it to your analysis, or whatever you need to do with it. If you want to maintain it across iterations, store it in a shift register.


Once you show us you code, we can give more specific advice. Of course there are ways to also write to a control terminal, but let's not go there yet.

0 Kudos
Message 4 of 16

@Eric1977 wrote:

Look into the Report Generation Toolkit. To get to that, go to the Block Diagram, right-click on any white space, then go under Programming - Report Generation - Excel Specific.

The way I understood the question is that reading from excel is not the problem, but things will be more clear once we see the code.

0 Kudos
Message 5 of 16

I don't really have much code written yet.  I am just experimenting trying to do the read part of it.  You can see where I read in 2 arrays, one called Simulated Torque Values and the other Brake data.  The first column of the Simulated Torque Value is actually degrees and the 2nd the torque value I would like to simulate.  This torque value would be used to control an electronic brake which would create a torque on the shaft based on the degree reading from an encoder.  The electronic brake is controlled by a voltage output that is proportional, but not linear to the torque the brake applies to the shaft, so I am reading that data in as well.  The 3rd array is just experimenting with finding the proper torque for the given angle.

0 Kudos
Message 6 of 16

So far you are not reading anything, so attach a typical input file too.


All your booleans seem to have the wrong mechanical action. Why not use the boolean text for a functional hint and keep the label concise?

What "control" did you have in mind in your original message? All you need to do is place the read data into a shift register and it will be available to all other cases via linked tunnels.

0 Kudos
Message 7 of 16

Good thing you started from a State Machine template.


There is a shift register (the rose one) that is used to store data accross all states you're coding.

Update the type-def of this cluster to include your arrays in it. Then read/write into the shift register wherever you need.




In LabVIEW, data are not necessarily linked to an object in the front panel.

Message 8 of 16

Can you post the file.  I can't read the snipit.  Thanks

0 Kudos
Message 9 of 16
Accepted by topic author Gizmo54

You can avoid all that duplicate code by reading both files the same way. No FOR loop needed.


Here's a quick sketch. (Since some of the plots are inside case structures, you should set "clear indicators when called". Also all buttons should be latch action so they reset to FALSE once read by the code. etc.)


For analysis, just unbundle in the relevant case.


Since these are all fast cases, you could use the event structure directly for all actions. No nee for the case structure.




0 Kudos
Message 10 of 16