Insert two blank rows after every row and copy paste columns

Hi, I’m a complete beginner to UiPath
So I have an excel file of around 5000 rows

I needed to insert two blank rows after each and insert the 3rd 4th 5th 6th column of every row to the next row’s 2nd column onwards like this

I wanted the output something like this

@samyak 1. Use the “Excel Application Scope” activity to open the Excel file.
2. Use the “Read Range” activity to read the data into a DataTable variable, let’s call it “inputDT”.
3. Add a “For Each Row” activity and set the DataTable property to “inputDT”.
4. Inside the loop, add the following activities:

  • Use the “Insert/Delete Rows” activity and set the properties as mentioned earlier.
  • Use the “Assign” activity to shift the columns. For example:
    • To shift the 3rd column (index 2) to the 2nd column (index 1):
      • Assign: row(index + 2).ToString
      • To: nextRow(index + 1)
  1. Save the modified DataTable to a new Excel file using the “Write Range” activity.


Follow the steps

  1. Read the data into datatable dt using read range activity
  2. Use assign activity and give as like this for a new datatable dt1 = dt.Clone
  3. Use for each row in datatable on dt
  4. Use add datatow inside it with dt1 as datatable and array row as {currentrow(0).ToString,currentrow(1).ToString,"","","","","",""}
  5. Use another add datatow again with dt1 and array row as {"",currentrow(2).ToString, currentrow(3).ToString, currentrow(4).ToString, currentrow(5).ToString,"", currentrow(6).ToString, currentrow(7).ToString}
  6. One more add datarow again on dt1 and array row as {}
  7. After the loop write the dt1 data to a excel file


It worked, Thank you :wink:


thank you :wink:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.