Question

I am exporting data from a p:dataTable into an excel file, and i the data in one of the columns in formatted in a special way using < br > tags.

Here is the layout: description

The problem is when i export the table, the < br > tags are printed into the excel document like this:

Excel description

The code i am using right now:

                <p:column sortBy="#{serviceLevel.titleAndDescription}">
                    <f:facet name="header">Description: </f:facet>
                    <h:outputText style="font-weight:bold" value="Title: &lt;br /&gt;" escape = "false"/>
                    <h:outputText value="#{serviceLevel.title} &lt;br /&gt; &lt;br /&gt;" escape = "false"/>
                    <h:outputText style="font-weight:bold" value="Description: &lt;br /&gt;" escape = "false"/>
                    <h:outputText value="#{serviceLevel.description}" />
                </p:column>

I have tried to use normal < br > tags between the outputText's which gave the same effect.

I have tried to use a < p:spacer > but the exporter doesn't support it :(

Any idea's on how i can keep the layout for the user, but not show the html tags in the exported excel document?

I am using Primefaces 3.5.

Was it helpful?

Solution

Thanks to SimonSez suggestion i managed to solve this issue with the help of some css.

Here is the solution i used:

            <p:column sortBy="#{serviceLevel.titleAndDescription}">
                    <f:facet name="header">Description: </f:facet>
                    <h:outputText style="font-weight:bold; display: block;" value="Title: " />
                    <h:outputText style="display: block;" value="#{serviceLevel.title}" />
                    <h:outputText style="font-weight:bold; display: block; padding-top: 20px;" value="Description: " />
                    <h:outputText value="#{serviceLevel.description}" />
                </p:column>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top