Get Excel worksheet names without using Excel

Hello,

I have a spreadsheet in the .xlsx format. This spreadsheet can have a dynamic number of worksheets, the worksheets will also be named dynamically.

REQUIREMENT:
I want to get the names of all worksheets present in the spreadsheet.

ISSUE:
The computer does not have Office installed on it and additional software cannot be installed. Also, packages from marketplace which may perform this function cannot be downloaded (the IT policy applied to by computer/network is very strict).


Does anyone know how I can get the names of worksheets without being able to open Excel or using other software?

@Clintonnn

You can try using invoke code and use closexml which does not required excel to be installed. Here is a sample code generated via chatgpt which can help as starter


    ' Path to your Excel file
    Dim filePath As String = "path\to\your\file.xlsx"
    
    ' Initialize a variable to hold the sheet names
    Dim sheetNames As String = ""

    ' Declare and load the workbook
    Dim workbook As XLWorkbook = New XLWorkbook(filePath)
    
    ' Iterate through the worksheets
    For Each sheet In workbook.Worksheets
        ' Add each sheet name to the string, separated by commas
        sheetNames &= sheet.Name & ", "
    Next
    
    ' Remove the trailing comma and space
    If sheetNames.EndsWith(", ") Then
        sheetNames = sheetNames.Substring(0, sheetNames.Length - 2)
    End If

    ' Output the sheet names
    Console.WriteLine("Sheet Names: " & sheetNames)

    ' Dispose of the workbook to free resources
    workbook.Dispose()

Library ClosedXML.Excel

Cheers

Thanks, but that code doesn’t work for me:
Error:
error BC30002: Type ‘XLWorkbook’ is not defined. At line 8
error BC30002: Type ‘XLWorkbook’ is not defined. At line 8
error BC30574: Option Strict On disallows late binding. At line 13 Main.xaml

Hi @Clintonnn

Check this

Regards,

Hie @Clintonnn use this activity to get all the names of sheets present in the excel
1- use excel application scope and pass the excel file
2- use get workbook sheets - and save the file name in the property section variable
3- use for each and pass the variable inside the for each

image
here is the list present in the excel


mark this solution if it finds you resolve your query
cheers Happy Automation