I want to copy columns from one data frame to another one but when copy a column in another data table that copies with a specific index number.
I try with following command for copy (Use assign activity)
newdatable=excelData.DefaultView.ToTable(False,“OB Cost Centre Code”,“Code”,“Days Present”,“Basic”)
after the above command used multi-assign activity for assign column names in new datable
newDatatable.Columns(“OB Cost Centre Code”).ColumnName=“Transaction Branch”
same for the remaining columns, but when try above it copies default index number,0,1,2,3,4…
want copy index number is like 7,8,9,10
Please guide me how to resolve Issue.
Do you want to change the column postion?
if yes then try using set ordinal
Issue/Query: How to change the ordinal or position of the DataColumn to the specified ordinal or position?
- The above scenario is achievable with the help of Set Ordinal method.
Sample Excel/ DataTable Data: Consider the below data
- Launch UiPath Studio and create a sample process.
- Ensure to have UiPath.Excel.Activities installed in Manage packages.
- From the Activities pane, search for Excel application scope/ Read Range (Workbook)/ Read CSV.
- For Illustration, drag ‘Excel Application Scope’ and ‘Read Range’ activity to the Designer pane to read the excel file.
- Ensure to set the below parameters:
Excel Application scope:
- Workbook path
- AutoSave (Optional)
- CreateNewFile (Optional)
- Read Only (Optional)
- Visible (Optional)
- AddHeaders (Optional)
- From the Activities pane, search for Invoke method activity and drag the same to the Designer pane.
- Ensure to set the below parameters in property pane of Invoke method activity:
TargetObject – readRangeOutput.Columns(“EmployeePayCheck(in $)”)
MethodName – SetOrdinal
Expand the Parameter property and set the ‘In’ parameter to 0 (See below)
Note: ‘In’ parameter is set based on column Indexing.
- The amended DataTable can now be further used for processing or for writing to Excel.
- To view the amended DataTable, drag ‘Output Data Table’ activity to the designer pane and set the Input(Datatable) and output (String) parameters.
- Use a Log Message activity/Message Box/Write Line to print the output to the console.
Hi @ashwini.mali ,
Could you let us know if you want to add these column values to an Excel sheet where there is already data present in it ? And you would want to append the data from last column ?
If you could provide an Input and Expected Output data, we would be able to clear our confusions and suggest you the proper approach.