I want to read last row from an excel sheet. Could any one please help.
You can achieve this in two steps:
- Get Total Rows in table →
dt.Rows.Count
-
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 )
https://forum.uipath.com/search?q=uipath%20excel%20read%20last%20row
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)
Thanks for your reply.I searched, but i did nit get solution from that. That’s why I posted.
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.
datatable.AsEnumerable().Skip(datatabl.erows.count-1)