Hello, i need support for excell automation with Oracle

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


name to be dynamic but it didn’t work what should i do.

1 Like

@mohamed.saty2012

You cannot set * …only exact sheet name to be given…

If using modern excel activity excel.currentsheet or excel.activesheet can be given without sheetname

If using classic then inside excel scope we can use get worksheets to get sheetname

Cheers

1 Like

if you check the print screen i am only using workbook read range inside for each file in folder

1 Like

@mohamed.saty2012,

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

Thanks,
Ashok :slight_smile:

1 Like

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

1 Like

1 Like

Is Microsoft Excel installed on the machine or will be available on Production machine?

1 Like

yes there is excel in the machine

1 Like

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.

1 Like

Hi @mohamed.saty2012 ,

There is a way to get the sheet names from the Excel/Workbook

  1. If you know the order of the sheet, you can use the “Get Workbook Sheet” activity. It’s like finding a specific page in a book.
  • Input : Index
  • Output : SheetName

  1. 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

Hope it helps you out!

2 Likes

@mohamed.saty2012

I saw you have a loop and workbook activity that is the reason i asked you to use excel scope activities

Cheers

1 Like

Use this logic to get all sheet names.

image

Once you have the sheet names in list variable then use the sheet name as per your business logic.

Thanks,
Ashok :slight_smile:

2 Likes

Thank you all for the great support. i am really appreciate it.

thanks this really works :smiley:

@mohamed.saty2012 ,

Glad it worked.
Happy Automation. :cherry_blossom:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.