Hello, I want to extract the sheet names from an Excel file using Excel Modern Activities. I don’t want to use the “Get Workbook Sheets” activity. How can I do this? I need to read the sheet names that follow a specific format (dd.MM.yy) and then save the most recent date.
Any specific reason for not using the activity designed for the same task?
Another option would be using VBA to get sheets names which I would say reinventing the wheel for which we already have the prebuilt activity.
Hey @nkaizer,
Use Excel Process Scope → inside it, drop a For Each Excel Sheet in Workbook activity.
In the loop:
If Regex.IsMatch(CurrentSheet.Name, "^\d{2}\.\d{2}\.\d{2}$") Then
dateSheets.Add(CurrentSheet.Name)
End If
After loop: latestSheet = dateSheets.OrderByDescending(Function(d) DateTime.ParseExact(d,“dd.MM.yy”,Nothing)).First()
Would you please explain the package in which this activity available?
because i want to use only excel activities . i want to use excel process scope instead of excel app scope
in the loop you put if activity ? for example in condition you put If Regex.IsMatch(CurrentSheet.Name, “^\d{2}.\d{2}.\d{2}$”)
and in then what activity you use?
thank you for your reply, where can i found this activity?
Use a simple If + Add to List pattern.
Assume you have a List(Of String) variable called dateSheets (initialized before the loop).
Inside For Each Excel Sheet in Workbook:
-
If activity
Condition:
System.Text.RegularExpressions.Regex.IsMatch(CurrentSheet.Name, “^\d{2}.\d{2}.\d{2}$”)Then:
Use Add to Collection activity
Collection: dateSheets
Item: CurrentSheet.Name
After the loop, you can get the latest sheet like this in an Assign:
latestSheet = dateSheets.OrderByDescending(Function(d) DateTime.ParseExact(d,“dd.MM.yy”,Nothing)).First()
instead of add to collection activity i use Append items to collection (because i cant find the add to collection) . is it the same?
Yes, that is fine use Append Item to Collection
thank you for your help. it works !!
Hi @nkaizer
Please check the below thread if you are using modern excel activities:
Regards
Parvathy
thank you for your help!!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.