Concatenate two columns from Excel Table


I want Write a productcode Like these “12A-2123” any one tell me how to write a code

Hi @killarapusiva

I assume by product code you mean a concatenation of column product and a substring of column code. In that case, loop over each row, and set Row("product code") = Row("product").Trim + "-" + Row("code").Trim.Substring(4,4)

Like this:
image

Alternatively, you can do the same by reading the sheet into memory, using a For Each Datarow activity, and then rewriting the sheet into Excel with a Write Range.

Kind Regards

1 Like

Hi @killarapusiva

Your steps would be as follows below

Read range the excel using excel read range

For each row in readDt

Assign

Currentrow(“Productcode”) = currentRow(“Product”).toString+“-”+Currentrow(“Code”).tostring.substring(Currentrow(“Code”).tostring.Length-4)

Out side the Loop

Write range with same path,sheet,datatable as readrange

Regards

Hi!

Assign:- Counter=1 ->Int32 variable

use write cell activity-> Value->

 CurrentRow("product").ToString.Trim+"-"+CurrentRow("code").ToString.Trim.Split("-".ToCharArray)(1).ToString.Substring(2,4)

Range in write cell: “D”+(Counter+1).ToString

Assign:- Counter=Counter+1

OutPut:-

Regards,
NaNi

Have a look here:
How to Update Data Column Values of a Data Table | Community Blog

the concatenation is a good case matching to the Datacolumn.Expression approach

1 Like

Nice, never knew about the DataColumn.Expression method.

Shame the article doesn’t include/compare execution time though.

Hi @killarapusiva,

Hope you have got your solution with such wonderful explanations from my fellow mates. Please tick the appropriate thread as the solution so that the thread can be closed and others can get help with it.

thanks

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