After WriteRange (workbook), System.Data.DataRow is output

Good evening
I am a user of UiPath Studio 2025.0.197STS Community edition.

  1. What I want to do

After creating a DataRow array arr_dr, I want to create an empty DataTable dt2, iterate through another DataTable dt using the ForEachRow activity, and add the DataRow array arr_dr to dt2 using the AddDataRow activity.

  1. What I’m struggling with

After adding the DataRow array arr_dr to dt2 and performing WriteRange (workbook), I got the output as shown in the attached image. What could be the cause?

Hi @gorby,

System.Data.DataRow indicates you’re adding the DataRow object instead of its values. Try using Row.ItemArray in the ArrayRow property of Add Data Row.

If that doesn’t work, could you share how you created arr_dr?

Thanks :blue_heart:

Unfortunately, I cannot accept your suggestion.
The reason is that setting Row.ItemArray with the Row’s ArrayRow property assigns the Row from dt instead of dt2.

arr_dr is created with the following syntax.

arr_dr = dt.AsEnumerable().
    OrderByDescending(Function(r) CInt(r("Population").ToString.Replace(",", ""))).
    ToArray()

Do you have any other good suggestions?

May Ganesha bless you.

@gorby

Use for each activity to iterate arr_dr

Inside it use Add data row activity to add the iterating row to the dt2.

After this for each, use write range.

Your suggested method will work, but I confirmed that if you execute dt2=dt.Copy() beforehand, you can also loop through the ForEachRow activity with Row.

Namaste :folded_hands: