How to get first and last row value of excel and append the same to new sheet

Continuing the discussion from I want the below value on division but unable to get:

@mahadev_biradar

if you want to get the first and last row ,Use the below expression

Dt.asenumerable.first

dt.asenumerable.last

or you want to get particular column value of the first row and last row

Dt.rows(0).item(“columnName”)

Dt.rows(dt.rows.count-1).item(“ColumnName”)

I got the records for first and last row but how to write it back to excel

@mahadev_biradar

use a write range…what difficulty do you ahve in writing it back?

cheers

I am getting two different values for first and last row with different in datarow but cant use write range activity for that

@mahadev_biradar

for single values you can use write cell activity

or can you explain more about your requirement

@mahadev_biradar

you can copy both in to one datatable and write

or write each row separately as well

or you can do this which will get only first and last into one table

requireddt = dt.AsEnumerable.Where(function(x,i) i=0 or i=dt.RowCount-1).CopyToDatatable

cheers

1 Like

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