With the example code below, if the objects in my listOfData have a ampersands in nameOfCompany, then excel will html encode the ampersand.
so,
A & A Corp
becomes
A & A Corp
in the excel file. How do I prevent the html encoding from occurring?
<m:message> <m:from address="test@test.com" /> <m:to address="test@test.com" /> <m:subject>Test</m:subject> <m:attachment fileName="test.xls"> <e:workbook><e:worksheet value="#{listOfData}" var="c"> <e:column style="xls-column-autosize:true"> <f:facet name="header"><e:cell value="Name" style="xls-background-color: grey_25_percent; xls-font-bold: true" /></f:facet> <e:cell templates="data"> #{c.nameOfCompany} </e:cell> </e:column> </e:worksheet></e:workbook> </e:worksheet> <m:body><html><body>Test body.</body></html></m:body> </m:message>
The following was suggested in another thread regarding email, perhaps it works in case of excel file creation, too.
<h:ouputText value="#{c.nameOfCompany}" escape="false" />
This will prevent from escaping & to &