Remove data from last row of an excel/datatable

Hi all,

I needed an expression to get the data of last row of an excel

Hi @Janani_T2

Check this expression out

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

This expression would remove the last row data

If you just want to get it

{dt.AsEnumerable.Last}.CopyToDataTable

1 Like

This is a linq expression right ?

Yes @Janani_T2 correct

Hi,

What type is your expected result?

DataTable

{dt.AsEnumerable.Last}.CopyToDataTable

Object array

dt.AsEnumerable.Last.ItemArray

Comma separated string

String.Join(",",dt.AsEnumerable.Last.ItemArray)

Regards,

1 Like

I just want to get last out of my datatable basically remove

Get as in I want to remove/delete it

Sorry, I had misunderstanding. @nikhil.girish 's expression will work.

Hi @Janani_T2

Try this

Hope this helps

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