LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from Excel-File and make selection from the first row

Hello, i have an Excel-File with 5 Columns and n Rows.
In the Sheet, 1. Row are Part-Numbers in the other Rows are important measure points.
I try to Read the first Row, make it visibil on the Frontpanel.
Then i would like to make a selection with a (maybe) Pull-Down Menu.
After selection the other Rows should be displayed on the Frontpanel.
I use LabView 7 Express
0 Kudos
Message 1 of 5
(3,691 Views)
You really have a lot of options here. The simplest would be to re-save the excel file as a tab-delimited text file. If all the cells are purely numbers, it's really easy - just use the Read From Spreadsheet File.vi in the File I/O pallet to give you a 2D array of values. If it's mixed strings/numbers, you can do a small modification to the same vi to give you a 2D array of strings (attached). You can then parse the array and convert the number strings to numbers.

Now, if you can't convert the file, you need to use ActiveX to gain access to excel. There are plenty of examples around on how to get the data from excel into a LV array. The jist of it is: open app reference, get workbooks object, open workbook, activate sheet (if not default s
heet), get range object (with range of cells needed), get range value, close range object, close workbooks object, quit excel application, close app reference.

Hope this helps.

Dave.
==============================================

Message 2 of 5
(3,691 Views)
Ok, to save it in Excel and as a text file is no problem.
What i would like to do is. The user can choose a Part Number.
When he has made his choice, all test parameters will be displayed on the screen.
The parameters are needed for other Vis in the program.
Therefor, the user should not be shocked by all the displayed parameters.
He should just look at the Part Number he has choosen.
I think the best way will be, to put the Part Numbers in a Pull-Down Menu (German: Kombinations-Feld <-> Kombination-Field?)

The help from Dave (Read from Spreadsheet file) is a good alternative but perhaps there are other oportunities?

Thanks

Kai Helms
0 Kudos
Message 3 of 5
(3,691 Views)
Get all the data from the spreadsheet into a 2D array in LV. Pick off the first row (part numbers) as a 1D array and assign this array as the choices in a menu ring by using the Strings[] property node. Then, when the user selects a part number from the menu ring, use the menu ring value (0 for first part number, 1 for second, etc.) as the index to pick off the correct column in the 2D array.

I've attached an example showing how to do this once you have the 2D array.

Dave.


Dave.
==============================================

0 Kudos
Message 4 of 5
(3,691 Views)
Yes, thanks. That works!
And looks even user friendly.
Thank you very much, again.

Greetings from Germany

Kai Helms
0 Kudos
Message 5 of 5
(3,691 Views)