For each row in Data Table
→ Add Data Row (new object() {strADB,strDate,strPOnumber,strLeadtime,strPIC,strCostcenter,strSupplier,CurrentRow(“ITEM DESCRIPTION”),CurrentRow(“QTY”),“”,CurrentRow(“UOM”),CurrentRow(“UNIT COST”),strDelivery,strCurrency,“”,strDiscount})
Then use Write DataTable to excel to display the output.
But now I want to make the strDiscount output 1 per strADB,
Before, every row is displaying the amount:
hi
since you are adding rows in a datatable and write one by one, you cannot directly achieve what you want directly..
So this is what i think you are looking for, grouping items based on “StrADB” and then write the 1st cell of the filtered Datatable with the value “strDiscount”..
try this approach:
Build datatable with all fields including strDiscount
for each StrADB unique values
{
add rows to the datatable with all the rest of the fields PER StrADB value excluding the discount amount(strDiscount).
Now calculate the StrDiscount value and update the “1st row of column StrDiscount” with the value of strDiscount.
now you have a table that has all the values you need plus the StrDiscount Value at row 1 and column “StrDiscount”.
If you want them in excel, use append range action to write these values to excel, with add headers flag off.
or if you want them in a datatable, you can use Dt_mainTable.Merge(Dt_temp, True, MissingSchemaAction.Add)
or merge action. (Dt_temp being your datatable that has data specific to StrADB value)
after writing, clear the data in the datatable.
}
this loop should continue for each and every StrADB.