List separators only between list elements

0
lukacs.akos posted this 17 August 2022

Hi!

I have a list of people (IEnumerable of .NET objects, each with a FullName property), and I need an output an inline list of them that has a coma and a space between each name. For example "John Smith, Joe Smith". Pretty much what String.Join(", ", names) would do. If I put the name + coma + space in the "List" in the word template, I will almost get what I need, but it will have a trailing space+coma. Is there a way to achieve this in word? Or should be precomputed with String.Join in the data source?

Saw you mentioned XPath for a similar questions: https://www.docentric.com/forum/chat/conditional-fields-and-separators Could you give an example?

Btw, do you have examples other than these? https://www.docentric.com/documentation/examples Evaluationg multiple solutions right now, and while I don't like Aspose's approach, they do have a lot of examples.

10 Posts
10 Points
1 Comments
Order By: Standard | Newest | Votes
0
jles posted this 19 August 2022

Hi Lucas,

I suggest that you first decide on the kind of a Data Source you are going to use. If you are going to stay with .NET Object based Data Sources, then you will need to create a calculated property that uses string.Join to concatenate strings, or the ElementInitialize to provide the same value on the fly: https://www.docentric.com/documentation/programming/generating-reports

Only if you decide to use XML based Data Sources you will be able to produce various values by writing XPath expression. In your case, you will be able to use the string-join XPath function.

-- Jure

155 Posts
295 Points

Our 228723 members have posted 344 times in 102 discussions