How to get specific set of rows between two fixed rows

Hi Guys!!

Here I have to get all the row items between the Header row & Total row. The number of row items between these two rows will change everytime. How can I get it?

Please help me to fix this
@Palaniyappan @Anil_G

Thanks in Advance

Hi @mohamedalthaf,

I suggest the following solution:

  1. Read the Excel (don’t forget to include headers)
  2. Loop on the data table using For Each Row in DataTable.\
  3. Inside the loop, add an If condition (CurrentRow(“Product Name”).ToString.ToUpper = “TOTAL”) and then add a Break activity on the Then part.

Hope this helps.

Kind regards,
Kenneth

1 Like

Hi,

Which data type as a result do you need?

If DataRow array, the following will work.

arrDataRow  = dt.AsEnumerable.Take(dt.Rows.Count-1).ToArray()

Dt is DataTable from worksheet. (Add Headers option is enabled.)

If DataTable, the following will work.

newDr  = dt.AsEnumerable.Take(dt.Rows.Count-1).CopyToDataTable()

Regards,

Hi @mohamedalthaf

  1. Read the data using read range and check the add headers check box
  2. Use filter datatable to filter the total row

Cheers

1 Like

Thank You @kennbalobalo . This is working

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