Trim column names

I have a datatable with column header names which has leading and trailing whitespaces. I want to remove them but not the ones in the middle.
For eg: " Column 1 " to “Column 1”

@Sweety_Girl
You can use TrimStart and TrimEnd on the String variable to achieve this.

2 Likes

Can you provide me complete syntax

Suppose the string is stored in a variable called StringText then

StringText.TrimStart.TrimEnd should work.

2 Likes

I need to trim the datatable columnnames

Please can you add a screenshot of the sequence. The approach should be similar but just wanted to check if that is what is needed.

1 Like

outDataTable.Columns(0).ColumnName.TrimStart()

1 Like

@Sweety_Girl

lets assume you have a datable in place with the columnnames having the beginning ending spaces.
so with a for each you can do name correction as following

grafik

Statement:
item.Columnname = itemColumnname.trim()

Dont forget to configure the typeargument of the for each to the datatype Datacolumn

4 Likes

Thank you so much

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