I have mentioned below characters to replace in Excel
currentRow.ToString.Replace(“#”,“”).Replace(“”,“A”).Replace(“+”,“”).Replace(“*”,“”).Replace(“$”,“”).Replace(“;”,“”).Replace(“/”,“”)
I have mentioned below characters to replace in Excel
currentRow.ToString.Replace(“#”,“”).Replace(“”,“A”).Replace(“+”,“”).Replace(“*”,“”).Replace(“$”,“”).Replace(“;”,“”).Replace(“/”,“”)
Try this:
System.Text.RegularExpressions.Regex.Replace(Input,"[#+*$;/Â]","").Trim()
Hope it helps!!
currentRow.ToString().Replace("#", "").Replace("Â", "A").Replace("+", "").Replace("*", "").Replace("$", "").Replace(";", "").Replace("/", "")
But i want for  is A
currentRow.ToString.Replace("#","").Replace("Â","A").Replace("+","").Replace("*","").Replace("$","").Replace(";","").Replace("/","")
Try this:
System.Text.RegularExpressions.Regex.Replace(Input,"[#+*$;/]","").ToString.Replace("Â","A").Trim()
Hope it helps!!
im getting this in message box
currentRow.ItemArray.Select(Function(item) If(TypeOf item Is String, DirectCast(item.ToString().Replace("#", "").Replace("Â", "A").Replace("+", "").Replace("*", "").Replace("$", "").Replace(";", "").Replace("/", ""), String), item)).ToArray()
I hope this helps you
You want to replace all rows and columns Special characters so above will help you
Or try this in Invoke Code:
dataTable.AsEnumerable().ToList().ForEach(Sub(row)
row("ColumnName") = row("ColumnName").ToString.Replace("#", "").Replace("Â", "A").Replace("+", "").Replace("*", "").Replace("$", "").Replace(";", "").Replace("/", "")
End Sub)
In Invoke Arguments:
dataTable
|| In/Out
|| System.Data.DataTable
|| yourdatatableName
Regards
If you want to replace one column then use this in for loop
Assign:
To: modifiedRow
Value: row("ColumnName").ToString().Replace("#", "").Replace("Â", "A").Replace("+", "").Replace("*", "").Replace("$", "").Replace(";", "").Replace("/", "")
2nd Approach
Perform read range
If you want to replace special characters to null to all rows and columns in datatable simply use this linq query
Dt=(From row In Dt.AsEnumerable()
Select Dt.Clone().Rows.Add(row.ItemArray.Select(Function(col) col.ToString().Replace("#", "").Replace("Â", "A").Replace("+", "").Replace("*", "").Replace("$", "").Replace(";", "").Replace("/", "")).ToArray())).CopyToDataTable()
okay but 1) I have like 167 columns so I want to replace it without mentioning column names
Assign:
To: modifiedRow
Value: row(“ColumnName”).ToString().Replace(“#”, “”).Replace(“”, “A”).Replace(“+”, “”).Replace(“*”, “”).Replace(“$”, “”).Replace(“;”, “”).Replace(“/”, “”)
You have 167 columns then try my second approach it will check all 167 columns if it find special characters then it will replace special characters to nul.
Read range
Assign activity---->Linq auery
Write range
I tried this LINQ query but the values not changing so for example I have mentioned a few samples
Ticked id column work column
#TDHF0131435 +919896546554
The above linq query is working fine for me
Sequence21.zip (1.7 KB)
Input:
Output
Try this:-
row(“YourColumnName”) = System.Text.RegularExpressions.Regex.Replace(row(“YourColumnName”).ToString(), “[^a-zA-Z0-9\s]+”, “”)
Try this:-
dtExcelData = (From row In dtExcelData.AsEnumerable()
Let newRow = row.ItemArray.Select(Function(cell) System.Text.RegularExpressions.Regex.Replace(cell.ToString(), “[^a-zA-Z0-9\s]+”, “”))
Select dtExcelData.Rows.Add(newRow.ToArray())).CopyToDataTable()
Thanks it working… apologies i did’nt check well
how to use this for 167 columns
(From row In dtExcelData.AsEnumerable()
Let newRow = row.ItemArray.Select(Function(cell) System.Text.RegularExpressions.Regex.Replace(cell.ToString(), “[^a-zA-Z0-9\s]+”, “”))
Select dtExcelData.Rows.Add(newRow.ToArray())).CopyToDataTable()
The LINQ query which I provided will work for all columns in one go. It iterates through each row in the DataTable (dtExcelData
), processes each cell in every row to remove special characters using a regular expression, and then creates a new DataTable (newRow.ToArray()
). This process is applied to all rows and columns in the original DataTable. Therefore, it will handle all 167 columns in one go.