Write a String to a document as a list

Hi

I have a String of names and am adding them to a document to replace other text. I would like the names to be shown as a list
Name 1
Name 2
etc

Rather than a string - Name1, Name2, etc.

Is anyone able to help please.

Thanks

Raychel

grafik

Lets assume a flatten comma seprated string. We would split and join it with a Linebreak

String.Join(Environment.Newline,YourStringVar.Split(","c))

@raychel.hall

-First, you’ll need to split the original string into an array of names.

namesArray = originalNamesString.Split(","c)

-Next, you can use the String.Join method to join the names with newline characters to create the desired list format.

namesListString = String.Join(Environment.NewLine, namesArray)

-Finally, you can display the namesListString in a message box

MessageBox.Show(namesListString, "List of Names")

Cheers…!

Hi, You can use below expression:

In Addition to above, we can extend and also trim the splits
grafik

For a better readability we would split it to two steps

Assign Activity:
arrSplits =

YourStringVar.".Split(",".ToCharArray, StringSplitOptions.RemoveEmptyEntries).Select(Function (x) x.Trim())

Assign Activity
strList = String.Join(Environment.NewLine, arrSplits)

@neha.upase Thank you, this has worked perfectly :slight_smile:

Regards

Raychel

1 Like

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