LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Filling a multicolumn listbox from excel

I am writing a vi in which I need to be able to fill a multicolumn listbox from an excel Spreadsheet.  The Spreadsheet will preferably be saved in .xlsm format but that can be changed if necessary.  I have the MS Office Report generation tool kit but have had little luck getting it to do what I want.  I have attached a sample spread sheet with the exact same formatting as the real one will have except it is in .xlsx because the NI forum apparently does not like .xlsm (the formatting can change as well if necessary).

0 Kudos
Message 1 of 7
(4,306 Views)

You said you had little luck. What exactly did you try? Were you able to read the contents of the workbook? Do you not know how to write to the listbox? What is your specific issue?

0 Kudos
Message 2 of 7
(4,291 Views)

Please post your VI.

 

This message board is not a write-a-VI for you service though some people seem to think so.

 

 

0 Kudos
Message 3 of 7
(4,280 Views)
I suspect that the RGTK does not like your file for the same reason as the NI forum. The .xlsm is the same as the .xlsx with embedded macro code. Does your Excel file need to contain code? If your system has all the current security patches, a giant red flag will be raised when the file is opened. There are several ways to remedy this, but the best solution is to avoid the .xlsm file format.
Michael Munroe, CLD, CTD, MCP
Automate 1M+ VI Search, Sort and Edit operations with Property Inspector 5.1, now with a new Interactive Window Manager!
Now supports full project automation using one-click custom macros or CLI.
0 Kudos
Message 4 of 7
(4,266 Views)

I was unable to find any feasible solutions using the Report generation tool kit but I may have missed something.  The reason I would prefer a .xlsm format is this database will be being updated from time to time and If I lock the workbook and put in some editing macros in it, I can ensure that the workbook has the proper number format and cell formatting.  I have not had any issues with getting security warning from my system as of yet but I know in the past I have made digital signatures and have given them trusted status in order to alleviate these types of issues.  Attached is the portion of my code that is doing the data importing.  So far this is as close as I have gotten (and it is still not right) and I had to change the file to .csv format.  If I change it to .xlsm or .xlsx it does not recognize the formatting and it just comes out as a bunch of random symbols.

0 Kudos
Message 5 of 7
(4,247 Views)

Hi, CSV files are definitely easier to handle however, you can implement something similar to this example to read the excel file. I hope this helps.

 

.xlsx to multicolumn listbox.png

Alejandro C. | National Instruments
Message 6 of 7
(4,238 Views)

Thank you alcava.cr with a slight modification to your program it did the trick.  I was misinterpreting the use of the new report block I was understanding it to create new reports not to create or open a report I guess I have a long way to go in learning labview.  Also thank you to everybody else who contributed you guys have saved me A LOT of time and I really appreciate your time and effort in the matter Smiley Happy

0 Kudos
Message 7 of 7
(4,221 Views)