I have a large excel file in which there are two columns A, B (with 10,000 rows).
I want to do Column A - Column B and store it in Column C. The answers I have seen in forum till now performs the operations on the excel cells one-by-one by changing the cell value and looping it.
Is there any solution if we can take the data into dt and add column C in dt and then perform the operation. and then write it into the excel?
Hi,
Please try loading into data table using excel application scope read range and then you can use for each to iterate through each row and then inside for each subtract ColA by ColB and then store in a variable and then move the variable a new data table which you should be creating before for each row activity.
Use a Read Range activity to read the data from your excel to a data table.
Use a Add Data Column activity to add a new column to the data table (Column C)
Use a For Each Row activity to loop through the data table
In the For Each Row activity within the loop and add the data to the new column
This is something similar which I have done to add a value to a new column
In your case, you can use Int32.Parse(row("ColumnA").ToString) - Int32.Parse(row("ColumnB").ToString) to do the calculation