From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Please explain workbook properties & List folder functions

Hi I'm having a bit of trouble setting these two functions up to work how I'd like and maybe I'm not using them in the right way.

 

Basically I need to know how to pull an excel sheet into my VI from a folder that contains 2 files (one is a .doc and the other .xls) for this I'm attempting to use the List folder function.

I know I can use a filepath to do this, but the file name changes periodically so I'd rather just grab the only .xls (if possible)

 

From that excel workbook, i need to access data that is on another sheet. I've been playing around with the front panel of the workbook properties but i'm not having any luck.

 

Any tips are much appreciated.

 

Thanks.

0 Kudos
Message 1 of 4
(2,799 Views)

This will get an xlsx file from the directory.  It doesn't handle the situation where a valid xlsx file is not found.

 

Do you have the report generation toolkit?  If so, switching to a different worksheet is a trivial thing, since there is a VI created to do that.

Example_VI_BD.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 2 of 4
(2,754 Views)

You can use the pattern input of the List Folder.vi to search for .xls  (.xlsx in my example). The Get Worksheet function is zero base so it should be set to 0 to get the first sheet. Data type should be a 2D array of string, with a string constant you will only get the content of the first cell in the range. In the true case you can insert a dialog that warn that no file was found.

 

Get File by Extension.png

 

Ben64

Message 3 of 4
(2,733 Views)

... and with a trivial modification to Ben's code (substituting *.xls* for the Pattern), you can find both .xls and .xlsx files (and, of course, .xlst, .xls8, .xlsthisisaverysillyexample).

 

Bob Schor

0 Kudos
Message 4 of 4
(2,721 Views)