Excel Automation Idea

Hi All,

Kindly help me with the automation idea. I have two Datatable i need to compare last column and make Final DT as shown below

DT1

Item Site UM
150275-37 217 EA 8000
150275-44 217 EA 352000

DT2

Location Lot/Serial Supplier Consignment
EBL02B2 L202405170027 4000
EBL02B2 L202405250026 4000
EBE06C1 L202405080004 104000

Final DT should be,

Item Number Site UM Location Lot/Serial Supplier Consignment
150275-37 217 EA EBL02B2 L202405170027 4,000.00
150275-37 217 EA EBL02B2 L202405250026 4,000.00
150275-44 217 EA EBE06C1 L202405080004 104,000.00
150275-44 217 EA EBE06C1 L202405170010 116,000.00
150275-44 217 EA EBE06C1 L202405240006 88,000.00
150275-44 217 EA einspec L202405290002 44,000.00

Thanks in advance,
Pavan

Hi @Pavan_kumar15

Check the below Invoke code:

finalDT = New DataTable()
finalDT.Columns.Add("Item Number", GetType(String))
finalDT.Columns.Add("Site", GetType(String))
finalDT.Columns.Add("UM", GetType(String))
finalDT.Columns.Add("Location", GetType(String))
finalDT.Columns.Add("Lot/Serial", GetType(String))
finalDT.Columns.Add("Supplier Consignment", GetType(String))

Dim query = From row1 In DT1.AsEnumerable()
            From row2 In DT2.AsEnumerable()
            Select New With {
                .ItemNumber = row1("Item").ToString(),
                .Site = row1("Site").ToString(),
                .UM = row1("UM").ToString(),
                .Location = row2("Location").ToString(),
                .LotSerial = "L" & DateTime.Now.ToString("yyyyMMdd") & row1("Item").ToString().Substring(row1("Item").ToString().Length - 4),
                .SupplierConsignment = String.Format("{0:N}", Convert.ToDouble(row2("Supplier Consignment").ToString()))
            }

For Each item In query
    finalDT.Rows.Add(item.ItemNumber, item.Site, item.UM, item.Location, item.LotSerial, item.SupplierConsignment)
Next

Invoke Code Arguments:

Direction Argument Name Argument Type
In DT1 DataTable
In DT2 DataTable
Out finalDT DataTable

Hope it helps!!

Hi @Pavan_kumar15

Build a new datatable final dt with the output dt columns

Assign finalDT = (From row1 In dt1.AsEnumerable()
                  From row2 In dt2.AsEnumerable()
                  Let ItemNumber = row1("Item").ToString()
                  Let Site = row1("Site").ToString()
                  Let UM = row1("UM").ToString()
                  Let Location = row2("Location").ToString()
                  Let LotSerial = "L" & Now.ToString("yyyyMMddHHmmssfff")
                  Let SupplierConsignment = row2("Supplier Consignment").ToString()
                  Select finalDT.Rows.Add(ItemNumber, Site, UM, Location, LotSerial, SupplierConsignment)).CopyToDataTable()

Hi @Parvathy ,

It is throwing error

Hi @pravallikapaluri ,

could you please provide me xaml file.

Anyone can help here ?