kavya.s16
(Kavya S16)
January 5, 2022, 8:30am
1
I have an excel sheet with different sheet names
Eg : 2021 - Ref , 2021 - Ref1 , Ref - 2020 and earlier , Ref1 - 2020 and earlier , Ended , Circulation sheet etc ----> these are the sheet names , year will be varying
I want to read only sheets with years and earlier like 2021 - Ref , Ref - 2020 and earlier and not Ended or circulation sheet
Please Help!!
thanks in advance
Srini84
(Srinivas Kadamati)
January 5, 2022, 8:50am
2
@kavya.s16
Welcome to forums
You can use Excel Application Scope and pass the File path with filename of the excel file
Use Get Sheets activity to get all the sheets
Now use For Each activity to loop into the sheets
Now use IF condition and mention as per your requirement
Hope this may help you
Thanks
Hi @ kavya.s16
Define the Sheet as dynamically…
Assign activity
sheetName =System.IO.Path.GetFileNameWithoutExtension(item.ToString)
It will dynamically pick the sheet name…
Thanks
Shyam
kavya.s16
(Kavya S16)
January 5, 2022, 9:20am
4
Can you please elaborate the if conditions according to the sheets names i have specified.
kavya.s16
(Kavya S16)
January 5, 2022, 9:21am
5
but case is that i want to read only particular pattern sheet not all.
Srini84
(Srinivas Kadamati)
January 5, 2022, 9:38am
6
@kavya.s16
You can write as below
Inside the For Each you can make a If condition and write as
Item.ToString <> “Ended” OR Item.ToString <> “Circulation Sheet”
So define your logic inside Then block
Else block what you want to do if the sheet is Ended or Circulation sheet
Hope this may help you
Thanks
kavya.s16
(Kavya S16)
January 5, 2022, 1:22pm
8
but what might be the condition other way round , reference or ended might not be constant, so i want some condition now.year - smc , but thing is i want for all years ,
like now.year - smc = 2022 - smc
what i need is = 2021 - smc , 2020 - smc , 2019 - smc etc
Hello @kavya.s16
Do you need to read the sheets with name XXXX - Ref and Ref - XXXX? Or just the sheets with name XXXX - Ref?
Srini84
(Srinivas Kadamati)
January 5, 2022, 1:36pm
10
@kavya.s16
Then you can use Regex IsMatch for that
Check below for your reference
Hope this may help you
Thanks
kavya.s16
(Kavya S16)
January 5, 2022, 1:48pm
11
there are totally 4 formats
1.2022(year keeps changing) — 2022 - ssc
2. 2022 - smc
3. ssc - 2021 and earlier
4. smc - 2021 and earlier
so basically years keeps varying.
kavya.s16
(Kavya S16)
January 5, 2022, 1:49pm
12
will try this , thank you
Okay, so try this with regex:
In IF activity:
System.Text.RegularExpressions.Regex.IsMatch(“\d{4} - \w{3}”, “\w{3} - \d{4}”)
I hope it helps!!
1 Like