Filtering Excel and writing the output to a different Excel file

I’m new to UiPath, trying to filter an Excel file and write the output to a new Excel.
I have been reading all kind of threads and articles but couldn’t find a straight answer to this task which I thought to be a simple one.

  1. I tried using ‘Filter Table’ activity, but this requires a name for the table. Is there a possibility to create the table name dynamically and not manually inside Excel?

  2. I tried to use Datatable.Select() that returns array of DataRow, then add it to a datatable and write it to Excel but no success. Many are recommending to read this article as an example:

https://www.uipath.com/kb-articles/how-to-filter-a-data-table

I followed all the steps in the article but i got the following error:

For Each: Unable to cast object of type ‘System.Double’ to type ‘System.String’

Any idea how solve this issue or just any simple example about filtering Excel and writing the output to another Excel file?

  • Use Read range activity within Excel application scope. You will get Datatable as output.
  • Use filter Datatable activity to filter with required criteria. And get another Datatable as output.
  • Use Write range within Excel application scope to write the output in another excel.

All this sounds good but how about the table name for ‘Filter Table’ activity. Can it be created dynamically inside UiPath? That’s the issue I’m facing.

I would solve this by using two datatables in the following method:
1 read range of the first Excel file (DT_Unfiltered)
2 assign DT_Filtered = DT_Unfiltered.Select(“[Column1] = ‘Criteria1’”).CopyToDatatable
3 write range to the second Excel (DT_Filtered)

Find attached an example workflow
Filter_Excel.xaml (8.5 KB)

5 Likes

Awesome…simple and neat! Thanks UiJules for the answer and for the useful example!

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