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?
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:
This code should save all excel table names from each worksheet and return them by list argument
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
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
When you say table, do you mean sheets - the tabs at the bottom of the Excel file? This will get a list of them:
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.
Hi can you help me for that please share the workflow I am facing some error
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
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.
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)