Excel column want to merge

Hello all, here in excel I want to merge the column from A1:D2 and want to write in one cell

Hi
Try with this custom component

Cheers @dhanashree22

1 Like

Hi!

take one build datatable and mention the colmname as ColMerge

1.read excel by using the read range
2.for each in datatable mention your dt out put.
3.multiple assign activity. in first assign create 1 variable called Col1 read the first column like this Row(“Columname”).tostring
4.repeat 3rd step for 2 times for Col2 and Col3 respectively.
5.take another assign activity and create a variable ColMerge=col1+col2+col3
6.Add data row. mention the datatable and in the properties panel in the array row{ColMerge}
this will update the data in to your build data table.

if you wants to do this in excel use write range and mention the range as E1.

Regards,
NaNi

hello here I get the error In For Each that you cannot implicitly convert type "System.data data table to "system.collection.IEnumerable. An explicit conversion is exist.
what should I do?
I mention the for each item In BuildDT

Hi,

Can you try the following steps?

First, use ExcelapplicationScope and ReadRange with the following settings.

AddHeaders: Off
Range : "A1:D2"
DataTable : dt (Make this as DataTable type in advance) 

Next, use the following expression in Assign activity

s = String.Join(vbLf,dt.AsEnumerable.Select(Function(r) String.Join(" ",dt.Columns.Cast(Of DataColumn).Select(Function(c) r(c).ToString))))

Finally use WriteCell activty with the following setting in ExcelApplicationScope

Range : Address you want to write to
Value : s

Regards,

the name Vblf does not exist in the current context
error come in assign activity

Hi,

Can you try to replace vbLf to chr(10) ?

Or do you use C#? the above is for vb.

Regards,

Hi,

Alright. As you use C#, I’ll rewrite for it.

Regards,

how to use c# here

I want
head 1| head2
abc xyz

I want op as head 1: abc , head 2 : xyz

Hi,

Can you try the following expression? This is for C#.

s = String.Join(",",dt.Columns.Cast<DataColumn>().Select(c=> String.Join(":",dt.AsEnumerable().Select(r=>r[c].ToString()))))

Regards,

Ok Thanks a lot. It work. But it works with heading values . I want
Heading: value, heading : value. what things to be add in that expression in assign activity

Hi,

Do you mean you need to add extra whitespace after colon and comma?
If so,can you try to modify "," to ", " and ":" to ": " in the expression.

Regards,

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