05-16-2018 08:17 AM
Hello !
After opening excel files in LV using Active X, I want to read data from each sheet existing in the file,That's why I put a listbox containing the sheets name that the user will select from it the sheet he wants to read.
The problem is that the sheets name are variable E.G : Sheet1 : AlternCurrent, it's written in different manners from file to other ( like: altern current or ALTERNCURRENT or Alternatif Current...), ( PS: I tried to get a list of all the name possibilities from the files)
I want to make labview recognize the sheet selected, independetly of how the sheet name is written, so to be generic to all files.
Does anyone has an idea how to solve this please
You will find attached the VI of Read excel file
Thank you in advance
Solved! Go to Solution.
05-16-2018 08:39 AM
Get Sheet Names of Selected workbook, then user can select the required sheet and read the values of specific sheet.
05-16-2018 08:39 AM
Hi Student,
you already read each sheet name so you "know" each name. What exactly is your problem?
I want to make labview recognize the sheet selected, independetly of how the sheet name is written, so to be generic to all files.
Then you need to implement an algorithm which is looking for "similarity" of strings!
05-16-2018 09:26 AM
Hello !
Thank you for this suggestion , as the sheet names change from file to other, i think it's better, as you said, to get all the sheet Names in the workbook and, then user can select the required sheet.
But any idea how to do this please with the VI that I attached above.
thank you
05-16-2018 09:45 AM
05-16-2018 09:58 AM
I'm assuming you have access to the Report Generation Toolkit (RGT), which has some Excel-specific functions that you need. Here are the steps you need to take -- I'm deliberately doing this without giving you the VI, as it will be more instructive (and you will be more likely to understand and remember how to do this) if you "do it yourself".
At this point, when you exit the For Loop, you'll have a list of all of the WorkSheet names in an Array. You can make any of those Worksheets be the Current Worksheet by executing another Excel Get Worksheet and either wiring the WorkSheet name in (a "bottom" input) or using the Array Index = Worksheet Index input.
Try building this simple VI and then "pointing it" (wiring the Template Name input) to a Workbook whose Worksheet names you know. Don't forget to do a Dispose Report to close Excel when you are done.
Bob Schor
05-16-2018 10:23 AM
05-16-2018 11:41 AM
Thank you for your responses
I look into the code that you suggested, it was helpful but still get error when I run my code, that i didn't know how to correct it
Please see the attached file
05-16-2018 03:41 PM
05-17-2018 10:16 AM
Hello
I did like you suggested to me,but I always find an undefined error code -2146777998.
I made modifications but still doesn't work;
Does anyone have any idea how to make the attached VI work ?
Please see attached VI
Thank you in advance !