I have an excel sheet from which I want to empty rows except 2 rows.
- Read Range - Dt
- Build datatable - outputDt
- Add Datarow - Dt.Rows(0) pass it in datarow field.
- Add Datarow - Dt.Rows(Dt.count-1) pass it in datarow field.
- OutputDt will have only first and last row.
my proposition is to use count, if and delete rows activity
First you are create additional datatable, and copy there first row and last row (based on count function).
Then you are deleting whole Excel and copy data from second datatable to excel
@kadiravan_kalidoss- i want to just empty the rows, so my final datatable should have all the Columns which are there in source datatable but the Values for first and last column should be filled , rest all the column values should be empty. Something like this
@pllo2ptk its something like below , i need output like the one which i shared,
you have mentioned about rows.
@Shailesh123 - Using a combination of read range, select range, and clear contents you should be able to achieve this.
NOTE: the ‘Get Last Row’ and ‘Get Last Column’ are part of the UiPathTeam.Excel.Extensions activity package
- Read range --> save as dt1
- Get Last Row activity --> save as lastRow
- Get Last Column activity --> save as lastColumn
- Select Range actitivy --> “B3” + LastColumn + (LastRow-1).ToString
- Clear contents activity --> leave the ‘All’ property and the ‘Clear’ property unchecked
Hi @Dave the select range, its throwing an error
Sorry i forgot the colon. Change it to
“B3:” + LastColumn + (LastRow-1).ToString
@Dave - I dont want to delete Last Column values, I want to delete values in between 1st and last column. This Select range deletes the last column and first column values, I want to delete last column-1 values
@Shailesh123 - Sorry i misread that portion. In that case, you should use the post here to get the last column as a alphabetic character. First get the 2nd to last column using
dt1.columns.count - 1 then use the idea from this post to convert it to the correct letter: Get last column of Excel sheet in Alphanumeric form