How to delete particular row from excel

Hi I want to remove row number 2 from my workbook.
How Can I delete the same.
Sample Columns.xlsx (8.5 KB).

@riddhi.vanawat

Use delete rows activity

Cheers

Hi @riddhi.vanawat

Try this

YourDataTable = YourDataTable.AsEnumerable().Skip(1).CopyToDataTable()

Hope it helps

Hi @riddhi.vanawat

Input:


Workflow:

=> Use Read Range Workbook to read the excel and store it in an datatable.
=> Use the below query in Assign activity:

dt= dt.AsEnumerable().Skip(1).CopyToDataTable()

=> Use Write Range Workbook to write the datatable back to excel.
xaml:
Sequence.xaml (7.7 KB)
Output:

Hope it helps!!

Hi @riddhi.vanawat ,
You can remove row only
1.read without header


2.deleterow 1st
image
3.write to new file or that file
image
my input

my outout

my source
RemoveRow.zip (15.4 KB)
Hope it help,

Hi @riddhi.vanawat

You can use the delete rows activity to delete the specified row in the excel. In your case, it is 2nd row.

→ Insert Use excel file activity and provide the path of the excel file
→ Inside use excel file activity insert the delete row activity and give the Excel.Sheet(“Sheetname”) in In what table or range field, In the At position field give the 1 with in double quotes (“1”) and select the Specific rows option in the What to delete dropdown.

Note : The first row will not consider as a row it was a header row that’s why we specified to delete the row as 1.

Check the below image for better understanding,

Input →
image

Output →
image

Hope it helps!!

Hi @riddhi.vanawat

Add an Invoke Method activity

  • Set the TargetObject property to dt.Rows.
  • Set the MethodName property to "RemoveAt".
  • Go to the Parameters collection, add a new parameter with:
    • Direction: In
    • Type: Int32
    • Value: 1 (to remove the second row).

OR

In the Write Range workbook you can uncheck the add headers thing from the properties panel

Use Read Range to read excel and then use for loop for datatable to identify exact row to delete or use linkq query to get exact row to delete then use delete row activity.

Hi… @riddhi.vanawat

By Using Skip function you can delete the rows based on your requirement, Check/Enable read headers in both read range and write Range activities as well

Hello @riddhi.vanawat
Use Insert/delete Rows Activity in the Excel application Scope.
Change the Property ofChangeMode as a “Remove” and Provide the Row number as a position.

If Need to Delete the Duplicate Values, Use REmove Duplicate Range activity in the application scope which delete the Duplicate values in the Range.
image