Source: Assign...Column does not belong to table DataTable

See below for the error

RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> RemoteException wrapping System.ArgumentException: Column ‘Price’ does not belong to table DataTable.
at System.Data.DataRow.GetDataColumn(String columnName)
at System.Data.DataRow.set_Item(String columnName, Object value)
— End of inner exception stack trace —
at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

The column “Price” exist with no data as data will be written to this column and confirmed the “AddHeaders” is checked

Assign

Hey. Change it to row.item(“Price”) and it will work if you’re in a For Each Row and there is a column named Price. Outside a For Each Row you can do it with dt.rows(intIndex).item(“Price”), where dt is the name of your datatable and intIndex is the row number. Kind regards, Anders

3 Likes

Hi Anders,

Apparently, the row.item(“Price”) didn’t work. I only have two columns in the excel one for pulling data and one where I want to wrte data(Column “Price”),

Ah ok, you wanna add data to an Excel Sheet.

Read the empty Excel sheet into a datatable, priceDT. Then Add Data Row to that datatable and in the property Array you write {“”,“8.88”}.

You can change 8.88 with you input variable from your get text.

Then finally write out your datatable to excel.

1 Like

Seems like this is too advanced for me. How do I do this? How do I convert it to Datatable?

Hey hungsty, check this. Given your Excel file has two columns as you said. Let me know, if that helps :slight_smile: I’ve attached the xaml.

Main.xaml (5.5 KB)

I still couldn’t figure. Download my XAML from the link below and excel is structured as follow:
Zip Code Price
80002
80238
80229

https://send.firefox.com/download/45d6a3c70db06fa0/#k5fHk72WHVmBGh2MOCDMRw

Everything works except for the assign step.

Here’s what the excel look like.

Excel

Your xaml is corrupted, but to solve this, you need to introduce an index variable in the For Each, so you can update the corresponding cell from Price. I’ve attached a working workflow. Just update the Get Text ‘Indicate on Screen’ and it will work.

Main.xaml (6.8 KB)

1 Like

It worked thanks so much. Can you tell me why my xaml was corrupted? Even I created a new same by introducing an index variable as yours and still didn’t work. Is there any reason for that?

1 Like

I honestly don’t know :frowning:

No worries…Your help is very much appreciated.

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