How to replace white spaces with hyphen in data table?

I have a data table with 13 columns and i want to replace the white spaces with the hyphen in the 1st column and then display that updated table in to excel sheet.
How can I achieve this?

HI @Sami_Rajput

Follow the below steps

  1. Read the excel sheet data in the DataTable variable name dt.
  2. Drag and drop the invoke code activity.
  3. In edit arguments, create a variable dt, set direction as in/out and pass value as dt.
  4. In edit code type the following,
dt.asenumerable.tolist.foreach(sub(row) row(“Column1”)= row(“Column1”).tostring.replace(“ ”,“-”))

Write the DataTable back into the excel using write range activity.

We have to use this inside invoke code as it does not produce a output.


1 Like


FYI, another approach:

If number of rows of your datatable is not very large, the following will work.


1 Like

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