Remove breaklines in data table

current:
image
theres hundreds of rows with above format in dt

i want to remove break lines for all rows
expected:

ive used col.ToString.Replace(vbCrLf, “”) in for each column, and it worked as expected when i write range to excel. however, when i paste it in google sheet it is still with the initial format.

@syezids,

Instead of vbCrLf try with “Environment.NewLine” once

i solved it with outputting the dt into string, do regex to remove breakline with space, and converting back to dt.
pretty sure theres better way to do this but this is working for my specific case

Hi @syezids ,

Give this a try in invoke code passign your dt as in/out arguement

Dim row As system.data.DataRow
Dim col As system.data.DataColumn
For Each row In dt.Rows
    For Each col  In dt.Columns
        If row(col.ColumnName).ToString().Contains(vbLf) Or row(col.ColumnName).ToString().Contains(vbCr) Then
            row(col.ColumnName) = row(col.ColumnName).ToString().Replace(vbLf, "").Replace(vbCr, "")
        End If
    Next
Next

Regards,

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