Datatable as text

Hello all,

I would like to display the values from a datatable as text and only the content from the corresponding cell, without “” & Enviorment.newline.

I have tried the following, but I am missing the commas:

System.Text.RegularExpressions.Regex.Replace(str_linq_OrderID,“\D”,“”)

Here is an example:

DT = “Test,” → Header
“1212,”
“2151514,”

Text output = 1212,2151514,

How can this be implemented?

use this
String.Join(",", dt.asenumerable.select(function(row) row.Field(of Integer)("Test")).ToList)

Example
image

result using write line
image

image

Note if the above code doesnt work , just change Integer to String
String.Join(",", dt.asenumerable.select(function(row) row.Field(of String)("Test")).ToList)

Hi @jack.chan
looks quite good, however I now have two commas between the values

"5345861,7656445,5121689,5301471,5492753,1820860,2838836,6163731,7859242,7606900,1047606,

do you have empty values in datatable? @NHoe
and i dont see 2 comma , i only see 1 extra comma at the end

There are no empty values in the table and this is what the output looks like when I take it into Set to Clipboard

5345861,7656445,5121689,

so you just want to get rid of this comma?
image

as soon as I put the post here the commas are missing, therefore by screenshot
doppelte Kommas

check if you have 1 comma here or 2 commas here

and does the values in your datatable contain commas? if it does do this
String.Join(",", dt.asenumerable.select(function(row) row.Field(of String)("Test").Replace(",", "")).ToList)

or this to replace , , with ,
String.Join(",", dt.asenumerable.select(function(row) row.Field(of String)("Test")).ToList).Replace(",,","")

1 Like

that’s how it works, thank you very much!

String.Join(“”, DT_Clone.asenumerable.select(function(row) row.Field(of String)(“Order_Number”)).ToList)

1 Like

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