How to deal with newline inside in a ColumnName from Datatable?


I met a problem that I have a datatable with some columnnames that there’re newline inside of it, and I couldn’t assign the value like below example:
If the ColumnName is “First Name”, and it stored in my Excel file will look like below in one cell:

when trying assign

DataRow(ColumnName) = “Value”

it got an error apparently there is no specific column existed since I used it the wrong way.

I also tried like:

DataRow(“First” + vbcrlf + “Name”) = “Value”
and obviously it’s wrong.

Could anyone give me some advice how to deal with it?

1 Like


Welcome to uipath forum

Instead of ColumnName you can try with column index as well

Say like this


Datarow(0) - first column
Datarow(1) - second column

Columnindex usually starts from 0 for first column
So you can mention accordingly

Cheers @Michael_Hsieh

1 Like


If you know index number of the column, can you try the following expression, for now?

String.Join(",",dt.Columns(0).ColumnName.Select(Function(c) AscW(c)))

We can know which character should be used from the output.


Hi @Michael_Hsieh ,

We could Change the Column Names as Required and then access the values using the Proper Column Names. For Instance, Trimming the Column Names can be done as provided in the Post below :

However, In your case along with Trimming, we would need to Remove New Lines with a Space.

we could try with the Following Expression :

item.ColumnName = item.ColumnName.ToString.Replace(Environment.NewLine," ").Trim

Let us know if it doesn’t work. We may need to use Regex to Replace NewLines