Excel rows division

Consider der are n rows. I need to divide the datatable for each 999 rows.
Example :
If the Excel sheets contains
1)1000 rows then two data tables need to be created one with 999 rows and the other with 1 row.
2)If the Excel contains less than 999 rows then the Single datatable is enough.

Please help me with this. Note : The EXcel Sheet contains the large amount of data

@Konda_Sai_Charan_Goud

Welcome to forums

Check as below

  1. Use Read Range activity and declare a Variable for Output in Datatable, Let’s say Dt
  2. Use Assign activity and write as DtRows = Dt.Rows.Count
  3. Use If condition and write as Dt.Rows.Count < 999
    Then : Nothing to do
    Else : Use Assign activity as First999dt = dt.AsEnumerable.Take(999).CopytoDatatable
    : Use Assign activity as Second999dt =
    dt.AsEnumerable.Skip(999).CopytoDatatable

Hope this may help you

Thanks

@Srini84

Hi, Thank you so much for your help.

But Can you also help me with how to know the DataTables count and add data into it accordingly.

The Row count is Random. We dont know the Count on before hand. We need to prepare enough datatables with 999 entries in each.

@Konda_Sai_Charan_Goud

You can use Dt.Rows.Count which will return the rows count

According to that you can divide that rows to 999

Hope this may help you

Thanks

1 Like