# StringCell

**URL:** <https://forum.knime.com/t/stringcell/190>\
**Category:** Node Development\
**Created:** [November 26, 2007, 11:48am UTC](https://forum.knime.com/t/stringcell/190 "2007-11-26T11:48:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![THINK](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/t/e9a140/32.png) [@THINK](https://forum.knime.com/u/THINK)\
**Post date:** [November 26, 2007, 11:48am UTC](https://forum.knime.com/t/stringcell/190/1 "2007-11-26T11:48:38Z")

</div>

I'm trying to create an output table which has several lines per row for one cell. However, when I create a StringCell with these lines separated by a linefeed (or other control characters) they appear to be stripped out. This contrasts with PDB and SDF cell types when linefeeds are retained. (The same string can be used to set a warning message with the linefeeds retained). Any suggestions?

---

<div class="post-metadata">

**Author:** ![unknown\_user](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/ac91a4/32.png) [@unknown\_user](https://forum.knime.com/u/unknown_user)\
**Post date:** [November 26, 2007, 12:41pm UTC](https://forum.knime.com/t/stringcell/190/2 "2007-11-26T12:41:40Z")

</div>

Hi THINK,

our StringCell implementation comes along with only an ordinary (JLabel) string representation, which strips special characters. PDB and SDF cells have a special renderer associated with them (org.knime.core.data.renderer.MultiLineStringValueRenderer), which retains the line breaks (and uses a fixed font).

We thought of adding this multi-line renderer also to StringCells but finally decided against it as in almost all cases the content is really only a small label. (And if not, they typically mean something special, such as SDF or PDB "strings".)

Quote:

> The same string can be used to set a warning message with the linefeeds retained

.  
I didn't get that one. Does it mean that you add warning and error messages to individual rows? If so (and you really don't care about the string content itself except for displaying in a table), you could put the string into an html body, for instance "This warning message is automatically wrapped.", in which case it will contain line breaks (and also display them). Please note, that this string is not suitable for further processing (I'm not sure what happens if you write it to a csv file...???).

Hope it helps,  
 Bernd

---

<div class="post-metadata">

**Author:** ![unknown\_user](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/ac91a4/32.png) [@unknown\_user](https://forum.knime.com/u/unknown_user)\
**Post date:** [November 26, 2007, 1:12pm UTC](https://forum.knime.com/t/stringcell/190/3 "2007-11-26T13:12:48Z")

</div>

Thanks for the prompt response.

I had jumped to the conclusion that I was doing something wrong rather than the render removing linefeeds! Hence my use of setWarningMessage to confirm that the linefeeds were in the string!

I hadn't realised that the String renderer was a HTML renderer which solves my immediate problem and which gives alot more scope ... is there a documented list of which HTML tags are permitted?

Thanks  
Keith

---

<div class="post-metadata">

**Author:** ![unknown\_user](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/ac91a4/32.png) [@unknown\_user](https://forum.knime.com/u/unknown_user)\
**Post date:** [November 26, 2007, 1:25pm UTC](https://forum.knime.com/t/stringcell/190/4 "2007-11-26T13:25:58Z")

</div>

I'm not sure whether we should advertise this html-feature much but since you've asked... it does use swing components after all, which means that the html functionality is limited to what swing allows you (see for instance here: [http://java.sun.com/docs/books/tutorial/uiswing/components/html.html](http://java.sun.com/docs/books/tutorial/uiswing/components/html.html))

Please be aware that KNIME treats the entire html source as a single string. You may get undesired behavior if you feed the strings to a row filter (and then filter on them), use a csv file writer, do cell splitting, use it in a java snippet node, etc.

Regards  
 Bernd

---

<div class="post-metadata">

**Author:** ![Sandro\_Boland](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/8c91f0/32.png) [@Sandro\_Boland](https://forum.knime.com/u/Sandro_Boland)\
**Post date:** [December 21, 2010, 10:27am UTC](https://forum.knime.com/t/stringcell/190/5 "2010-12-21T10:27:32Z")

</div>

I think this topic is ralated to what I need, but I don't really know how to implement it...

For practical reasons, I would indeed like to put several lines of text in a single row, in order to create some short summaries.

Here is my current situation.

I am currently creating reports about the biological activity of chemical compounds. As it is now, my reports have the following form.

**_RowID&nbsp;&nbsp;&nbsp; Structure&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Target & Activity_**

_1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Compound1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Target1 xxxnM_

_2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Compound1 &nbsp;&nbsp;&nbsp;&nbsp; Target2 xxxnM_

_3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Compound1 &nbsp;&nbsp;&nbsp;&nbsp; Target3 xxxnM_

_4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Compound1 &nbsp;&nbsp;&nbsp;&nbsp; Target4 xxxnM_

_5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Compound2 &nbsp;&nbsp;&nbsp;&nbsp; Target1 xxxnM_

_....._

This means that a depiction of a structure is reapeated multiple times (one for each activity). This is not practical when making reports: I need to depict relatively complex structures (typically no more than 5 -6 pictures per page)... Once you start testing a compound on multiple targets , the same structure can be repeated over and over again, across multiple pages, with almost nothing written in the neighboring cells. The would be ample space for a short summary in the activity cells.

**_RowID&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; Structure&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp; Target & Activity_**

_1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; Compound1&nbsp; | &nbsp; Target1 xxxnM_

_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; | &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; | &nbsp;&nbsp; Target2 xxxnM_

_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; | &nbsp;&nbsp; Target3 xxxnM_

_&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; | &nbsp;&nbsp; Target4 xxxnM_

_2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp; Compound2 &nbsp; | &nbsp; Target1 xxxnM_

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; _Target2 xxxnM_

I could of course use a concatenate option while using a "group by" node, but again, it's far from clear... Having the possibility of a multi-line cell when using "group by" would be way better.

Any option for this? Either in the node or by editing the contents of the cell after group\_by would be fine. There is a discussion in this topic about using html codes, but I don't really know how to implement this. Can anyone provide me with a worked-out example?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![gabriel](https://forum-cdn.knime.com/user_avatar/forum.knime.com/gabriel/32/61386_2.png) [@gabriel](https://forum.knime.com/u/gabriel)\
**Post date:** [December 21, 2010, 2:47pm UTC](https://forum.knime.com/t/stringcell/190/6 "2010-12-21T14:47:35Z")

</div>

Hi Sandro,

I think using the Group-By node is the best way to go by creating a list of cells. As a next step, I would apply the Java Snippet node generating some kind of single html-formatted StringCell:

```
Double[] values = $column$;
StringBuilder ret = new StringBuilder();
for (int i = 0; i < values.length; i++) {
  ret.append("<p>" + values[i] + "</p>");
}
return "<html><body>" + ret.toString() + "</html></body>";

Regards, Thomas
```

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:14pm UTC](https://forum.knime.com/t/stringcell/190/7 "2023-06-23T20:14:15Z")

</div>


