URGENT PLEASE HELP HOW TO DELETE DYNAMIC EXCEL LAST ROW DATA?

i have a UiPath flow
read the CSV file, then write all the CSV data into Excel.

When it is finished it becomes data in Excel, because the data dynamically follows the data in CSV

after that, I want to delete the last two rows in dynamic excel data

How to delete dynamic Excel last row data?

Hello

Try these options:
Option1:

Option2:
dt.AsEnumerable().SkipLast(2).CopyToDataTable()

Note: this may not work depending on your version of the REF - as it only works in “Windows-Legacy” method only.

Hopefully this helps,

Cheers

Steve

Hi @Kia1 ,

You can do this as below,

Final_DT.AsEnumerable().Take(Final_DT.Rows.Count - 2).CopyToDataTable

selects all the rows from the DataTable Final_DT except the last two rows and creates a new DataTable containing those rows.

Regards,
Vinit Mhatre

Hi @Kia1

Try this

(Excel.Sheet("Sheet1").DataTableValue.RowCount-1).ToString+"-"+(Excel.Sheet("Sheet1").DataTableValue.RowCount).ToString

Input:

image

Output:

image

Note: If you want to remove only last row use the below

(Excel.Sheet("Sheet1").DataTableValue.RowCount).ToString

Regards,

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