Getting entire row from data table and pasting that entire row data in an new excel

My scenario:

  1. Navigate to https://www.rpasamples.com/

  2. Click on “Sales Opportunities”
    Extract a data table from a web page
    save it to a data table
    image

  3. You will be able to see multiple countries in the “Country” column.

  4. We need to filter out the details based on each country and place them in different excel sheets.
    ex. if country name=India then past the entire row data in that India named excel

Very simply you can copy the selected row from the source DataTable into a one-row target DataTable and then call WriteRange to write this DataTable to Excel (Add Headers = false).

It would create the same effect as copying an entire row to Excel.
If you have to repeat this process then you have to keep track of the last cell number where you wrote the previous row.

For example if you wrote the first row to cell A1, then you keep track of the fact that a row beginning in this cell is populated. When you paste the next row, your starting cell will be A2

Thanks

@deepaksvg99

Welcome back to our UiPath community.

Hope you are able to scrape the table data. If yes then it will give output as DataTable. Let’s say ‘InputDT’.

          CountryDT = InputDT.DefaultView.ToTable(True,"Country")
          For Each row in CountryDT
              UniqueCountryDT = InputDT.Select("Country = '"+row("Country").ToString+"'").CopyToDataTable
              Use Write Range activity and pass UniqueCountryDT DataTable and sheet name as row("Country").ToString

The above method will create separate sheet for each country and will write data into it.

Hi @deepaksvg99

You can try with Filter Data Table
image

Regards
Sudharsan

Thanks Lakshman it worked

1 Like

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