Hi, I have a process that writes log entries into an Excel sheet. With each execution the robot writes 5-100 rows. How could I make that sheet to only contain the last 500 rows? Thank you
So while writing are you reading the excel for anything?
- Do you want to have the last 500 including the records that you are inserting or do you want to have the last 500 before inserting the records?
Depending on the above where you add the following tasks may vary…
To get the last 500 records.
- Read the excel into a data table using read range
- Use a sort data table activity to sort the records in descending order. May be you can use a date or a row ID which is available.
- Then use a for each row activity with a count of 500 row limit and do a write range to excel
- Read data into a data table.
- get the count of data table.
- if count > 500
skipRows = count - 500
newdt = myDataTable.AsEnumerable().Skip(skipRows).Take(500).CopyToDataTable
Skip - Will skip the unwanted rows
Take - Will take the next 500 rows
- Save the newdt to a new excel file using write Range.
@KarthikByggari So it will skip starting from the top of the table, right?
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.