Add column name using Data table

Heloo guys,

how can i add a column name on a specific column index using Data Table activity instead of write cell

since the excel is having large data it is taking more time while using Write cell

Hi @Gokul_Murali

Check the below thread

Syntax:

dt_Result1.Columns.Add("").SetOrdinal(6)

Change the number accordin to yours and within doubke quotes give your column name.

Let me know if you have any issues

Regards

Hi @Gokul_Murali ,

Could you maybe check with the below post :

When using SetOrdinal method, first add the column to the Datatable using Add Data Column activity and then use the SetOrdinal method.

We could also re-arrange the columns if we do know the column arrangements and all the columns required for the output using the DefaultView.ToTable() method.

This is the error iam getting and the datatable is declared in the scope itself

Hi @Gokul_Murali

Count the number where BO15 comes so it is 67.

Give 67 instead of BO15

Regards

It is showing like this

Hi @Gokul_Murali

Did you map the arguments by clicking on Edit Arguments.

Regards

Now iam getting error like this

Hi @Gokul_Murali

Give the argument as In/Out not on In.

Regards

still the same

Hi @Gokul_Murali

Can you share the entire flow.

Regards

Hi @Gokul_Murali

Or share the excel file.

Regards

Test case.zip (8.9 KB)

Hi @Gokul_Murali

Please check the below zip file.

FLOW:

CODE:
dt_PR.Columns.Add("GOC").SetOrdinal(66)

INVOKED ARGUMENTS:

ZIP FILE:
Add column to datatable.zip (47.8 KB)

Let me know if you have any issues.

Regards

Bro iam getting the same error.

Hi @Gokul_Murali

Bro check that I have change the code in Invoke Code.

dt_PR.Columns.Add("GOC").SetOrdinal(66)

If this doesn’t work please update UiPath.System.Activities to the latest version.

Regards

Same case bro

even i updates the package version to the latest version

Hi @Gokul_Murali

Check that i have changed the code:
dt_PR.Columns.Add("GOC").SetOrdinal(66)

Instead of 67 give 66

Regards

Hi @Gokul_Murali ,

U can achieve the same by using

syntax :- dt_Result1.Columns.Add("Column name ").SetOrdinal(Columnposition-1)

Regards
Sandy

Bro i have tried it but the same case