Delete specific number of rows in an excel

Hi All,

I need to delete certain number of rows in an excel. The scenario is, open an excel, delete first 20 rows and save the result in new excel sheet. Here, the number 20 is dynamic (i.e.)it may vary on each run.

Requesting your help in finding the solution.

Thanks,
Shahidh Aqeel

dtData.AsEnumerable.Skip(20).CopyToDatatable
dtData.AsEnumerable.Skip(YourIntVar).CopyToDatatable

another option could be to set the range offset to a downer row e.g. A21 when readin the excel

@shahidh.aqeel.shahul

Hope you know all columns and count is constant.

If yes then use Delete Range activity inside Excel Application Scope activity and pass below parameters to it.

   Range: "A2:L"+DeleteRowsCount.ToString
   SheetName: "Excel SheetName"
   Select ShiftCells checkbox and ShiptOptions as ShiftUp

Note: Replace L with ending column in your Input Excel file.

This solution worked. Thank you.

Hi Lakshman, Thanks for your response. Got the solution now.

1 Like