How can I find the name of all tables in Excel?

I have 20 tables in excel and I want to add a data to all of these tables.
For this, I plan to process the data by learning the table names and returning them for each.

How can I do it?

Hi @ekseri

Can you share the sample input and expect output

If no activity is able to extract all table names from excel file there is option to make it using invoke code:

Dim excel As Application = New Application
Dim workBook As Workbook = excel.Workbooks.Open("YourPathToExcelFile")
Dim workSheet As Worksheet
Dim excelTable As ListObject
listOfTableNames = New List(Of String)

For Each workSheet In workBook.Worksheets
	For Each excelTable In workSheet.ListObjects
		listOfTableNames.Add(excelTable.Name)
	Next excelTable
Next

excel.Quit

With list out argument:

It should work with that namespace imported:
Capture

This code should save all excel table names from each worksheet and return them by list argument

1 Like



image
Where am i doing wrong?

Just replace first 2 lines with:

Dim excel As Application = New Microsoft.Office.Interop.Excel.Application
Dim workBook As Microsoft.Office.Interop.Excel.Workbook = excel.Workbooks.Open("YourPathToExcelFile")

You have 2 different types named ‘Application’ and ‘Workbook’.
UiPath does not know which one has to choose :smiley:
We have to clarify from which namespace we want to use that types.
After changing ‘Application’ to full object name ‘Microsoft.Office.Interop.Excel.Application’ error should disappear. Its good to remember what this error means :wink:

1 Like

When you say table, do you mean sheets - the tabs at the bottom of the Excel file? This will get a list of them:

image

It does not give an error, but there is no data in the list.

Have you ever tried the code? Does it work?

No, it’s not the sheet names I want to ask.

I am trying to find the table names contained in the Excel file.

Hi @ekseri ,

Make sure you have given the Direction of the list argument as Out in Invoke Code Activity.

1 Like

I am getting error can you please share the solution

Hi can you help me for that please share the workflow I am facing some error

Have you gone Excel and enabled “Trust access to the VBA project object model?”

1 Like

Dim excel As Application = New Microsoft.Office.Interop.Excel.Application
Dim workBook As Microsoft.Office.Interop.Excel.Workbook = excel.Workbooks.Open(“C:\Users\Aleem Anwar\Documents\UiPath\get all name of table\files\1.xlsx”)
Dim workSheet As Worksheet
Dim excelTable As ListObject
listOfTableNames = New List(Of String)

For Each workSheet In workBook.Worksheets
For Each excelTable In workSheet.ListObjects
listOfTableNames.Add(excelTable.Name)
Next excelTable
Next

excel.Quit


1.xlsx (11.4 KB)

I have two table in excel and I need to find all name using this code.Please help me where I am wrong
Main.xaml (10.5 KB)

I would avoid dim-ing a variable with the same name as the type.

Seems like error related to excel library.
I have never seen this.
Maybe try to install Microsoft.Office.Interop.Excel nuget

I have imported this package from import tab

You don’t install packages from the import tab. You use the Manage Packages button at the top.

I have install but still get error please help guys

That screenshot doesn’t show us what the error message is. Give us the first few red lines in your Output (in other words, scroll up to the beginning of the error)