could anyone please kindly help, how can I read data without last row from specific worksheet. And past data in another worksheet just before last row, without removing existing data.
Use read range and then use assign to get data without last row dt = dt.AsEnumerable.Take(dt.RowCount-1).CopyToDataTable
Then use a write range and give dt as input to second sheet
If you want to delete last row…then inside use excel file, use delete rows with range as Excel.SelectedSheet.RowCount
add minus 1 or plus 1 as per your table requirement in excel
Hope this helps
Cheers
Hi @Sabbir_Anwar ,
If using the Modern Excel activities, you could check the below Workflow :
Excel_AppendData_BetweenSheets.zip (15.7 KB)
- You would require to use two
Use Excel File
activities, one inside another. - Then the
Append Range
activity should be able to help by Specifying the Proper Ranges in the Properties.
Excel Range to Append :
Excel1.Sheet("Sheet1").Range("A1:"+UiPath.Excel.Helpers.ExcelUtilities.ConvertColumnIndexToColumnLetter(Excel1.Sheet("Sheet1").GetTableOrRangeColumns.Count)+(Excel1.Sheet("Sheet1").RowCount-1).ToString)
Append after Range :
Excel2.Sheet("Sheet1").Range("A1:"+UiPath.Excel.Helpers.ExcelUtilities.ConvertColumnIndexToColumnLetter(Excel2.Sheet("Sheet1").GetTableOrRangeColumns.Count)+(Excel2.Sheet("Sheet1").RowCount).ToString)
Here, Excel1
specifies the worksheet instance which has the data to copy, Excel2
is the instance which specifies where you want to copy.
Check the Excel files in the Project, Execute the workflow and check the Excel 2, The data should be appended from Excel 1 to Excel 2.
Let us know if the append doesn’t work as expected.
Note: When specified as Worksheets, we assumed two Excel files, and hence the Setup. If the copy / append is to be performed within the same Excel file between sheets, we could easily modify the same workflow as well.