How to Add Multiple Data Columns To A Datatable At Once?

studio

#1

Is it possible to do something like this?

image


#2

Hi @whyyouandi,

Its not possible instead of this you can add from the build data table it self you can add the columns

Regards,
Arivu


#3

Hello @arivu96, I was trying to add columns to an existing data scraping data, so I cannot use Build Data Table. But thank you for mentioning that it is not possible to do that at once :slight_smile:


#4

Hi @whyyouandi,

You can use multiple add data column activity.

Regards,
Arivu


#5

Yes, thank you.


#6

@whyyouandi, You can add multiple columns in datatable using AddRange method.

Need to use Invoke Method

TargetObject - datatable Variable.Columns
MethodName - AddRange
Parameters - 
IN - DataColumn[] - { new DataColumn ("columnName1"), new DataColumn ("columnName2") }

Regards,
Dom :slight_smile:


#7

HI @whyyouandi,
Good Idea @Dominic,
Its working fine
AddMultipleDataColumn.xaml (10.0 KB)

Regards,
Arivu


Get column name from first row in DataTable
How to add custom headers and data in Write CSV
#8

Thank you @Dominic, exactly what I wanted! Always thank you! :star_struck:

And thank you @arivu96 for assembling it into .xaml, would have struggle without it!
(Set the solution to the arivue96’s one since I think the end result will be easier to be understood for anyone reading this thread if any).