i have and automation where the Robot open oracle application and select data from excel sheet.
currently the sheet name is fixed but once the end user will send the data the sheet name will be different each time and the robot will not be able to find the sheet as it different name. i have tried to set “*” instead of the sheet
You cannot use * as dynamic Sheet selector.
You will have to give fixed Sheet name. There should be some fix logic like Sheet number or name where your data would be.
If there is going to only one sheet but name cannot be fixed then use below code in invoke code which will return you Sheet name. [Not tested but you can customize it as per your need]. This will also work on the machine where Excel is not installed because it’s using ClosedXML
Imports System
Imports ClosedXML.Excel
Public Class GetSheetNames
Public Sub Execute()
Dim workbookPath As String = "C:\path\to\your\workbook.xlsx"
Try
Using workbook As New XLWorkbook(workbookPath)
Dim sheetNames As New List(Of String)()
For Each worksheet As IXLWorksheet In workbook.Worksheets
sheetNames.Add(worksheet.Name)
Next
' Output the sheet names (can be customized as per your requirement)
For Each sheetName As String In sheetNames
Console.WriteLine(sheetName)
Next
End Using
Catch ex As Exception
Console.WriteLine("Error occurred: " & ex.Message)
End Try
End Sub
End Class
let me be clearer. i am using for ech file in folder and the activity in the print screen is inside it all i need is to set a variable that can hold the sheet names every time it changes then i can use it in the sheet name instead of fixed name. how can i do this
for more info the end users will send the file so in the for each activity the robot should handle any file with different sheet name. the current automation is set on a fixed sheet name but in the future the sheet name will change according to the users.
If you want all the names of sheets in the workbook and want to read them, you can use the “Get workbook Sheets” Activity. It’s like getting a list of all the chapters in a book.
Input : Nothing
Output : List Of Sheetnames present in that specific Excel