Read and write last row

I want to read last row from an excel sheet. Could any one please help.

Hi @Sabbir_Anwar

You can achieve this in two steps:

  1. Get Total Rows in table → dt.Rows.Count
  2. dr = dt.Rows(RowCount - 1)
    dt is a DataTable object, dr is DataRow.
    The dr object can then be used to retrieve column values as needed.

Please use the search feature on Forums to look up answers for simple questions such as this one. It’s always likely that someone has already had this problem and it’s resolved.
This will save you a lot of time (and community members too :slight_smile: )

https://forum.uipath.com/search?q=uipath%20excel%20read%20last%20row

3 Likes

You can use read range to extract the sheet data into a datatable and use datatable.rows.count-1 to get the last row index and use it however you want.

here is an exemple :
Read_Last_Row.xaml (10.5 KB)

1 Like

Thanks for your reply.I searched, but i did nit get solution from that. That’s why I posted.

1 Like

Thanks for your reply. But the project you provided is not running.

Hi @Sabbir_Anwar,
Use below code to get last row.
DataRow dr= dt.Rows(dt.Rows.Count-1)

To access last row values

dr(“ColumnName”).TosString()

Regards,
Arivu

Hey

You created another post with the same topic, please close one of them

Regards

I read last row by using “dt.AsEnumerable.Last”

But when i want to write, it write whole sheet, not only the last row. But I want to write only last row.

I read last row by using “dt.AsEnumerable.Last”

But when i want to write, it write whole sheet, not only the last row. But I want to write only last row. Please kindly help.

I read last row by using “dt.AsEnumerable.Last”

But when i want to write, it write whole sheet, not only the last row. But I want to write only last row. Please kindly help me.

Hey

please give a try with this example

Main.xaml (8.1 KB)

Regards

datatable.AsEnumerable().Skip(datatabl.erows.count-1)

1 Like