Adding a 2 columns between columns

Hey @Priyesh_Shetty ,

You can add new columns in your Excel sheet using various approaches. Here are five methods you might consider:

Approach 1: Default View

  • Add the 2 columns - “Today” and “Pending qty” using “Add Data Column” Activity
  • Set your Assign block as following image

dt_input.DefaultView.ToTable(False,"PO NO","Today","INVOICE QTY","CAPEX/OPEX","Pending qty")

Approach 2: Set Ordinal - Invoke Method

Approach 3: Inserting Columns Using Excel Activities

Approach 4: Invoke Code

  • Use the “Invoke Code” activity to write a small snippet of VB.NET code to insert columns programmatically.
Try
    Dim todayColumn As New DataColumn("Today", GetType(String))
    dtData.Columns.Add(todayColumn)
    dtData.Columns("Today").SetOrdinal(1) ' Adjust "1" to set it between "PO No" and "Invoice Qty"

    Dim pendingQtyColumn As New DataColumn("Pending qty", GetType(String))
    dtData.Columns.Add(pendingQtyColumn)
    dtData.Columns("Pending qty").SetOrdinal(4) ' Adjust "5" to set it after "Capex/Opex"

Catch ex As Exception
    Console.WriteLine(ex.Message)
End Try

Approach 5: Template File

Please find All the approaches in the below Zip File

Adding_Column.zip (64.6 KB)

Hope it helps you!
Regards,
Vikas M

2 Likes