How to select the data in excel?

Hi All,

I need to select the some data from an excel as below:

There are 100 rows and 12 columns, I need to select the things as below:

1.How to fetch the first and last record from the excel(including header).
2. How to fetch the 50th row and 7th column from the excel.

Please help me to solve this.

@Palaniyappan
@ppr
@Yoichi
@Gokul001
@Rahul_Unnikrishnan

Hi,

First read table in the sheet as datatable using ReadRange activity (Let’s say dt)

DataRow of the first row

dt.AsEnumerable.First()

Some item of the first row

dt.AsEnumerable.First().item("ColumnName")

DataRow of the last row

dt.AsEnumerable.Last()

Some item of the first row

dt.AsEnumerable.Last().item("ColumnName")

How to fetch the 50th row and 7th column from the excel.

dt.Rows(48)(6)

Regards,

2 Likes

@Vrishchik

For fisrt record

Datatablevaraible.AsEnumerable.take(1).CopyToDataTable

Datatablevaraible.AsEnumerable.skip(datatbale.rows.count-1).take(1).CopyToDataTable

For second scenario use below expression

dt.rows(49)(“7thcolumnname”)

Gives the value

Cheers

1 Like

why 48 for 50th row??

Hi,

As row of datatable is 0-based index. So if there is column header, excel row 2 is assigned 0th row of datatable, as the following.

image

If there is no header (read range without header), it will be 49.

Regards,

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