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

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

2 Likes