04-25-2016 11:16 PM
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.
04-26-2016 09:33 AM
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.
04-26-2016 12:32 PM
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.
Ben64
04-26-2016 01:24 PM
... 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