Skip to content

Instantly share code, notes, and snippets.

@bennadel
Created March 25, 2014 00:49
Maintaining Line Breaks In An HTML-Excel File
<br style="mso-data-placement:same-cell;" />
<!--- Store Excel-HTML output. --->
<cfsavecontent variable="strData">
<table border=".5pt">
<thead>
<tr>
<th>
Degree
</th>
<th>
Year
</th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td>
Highschool Diploma
<br style="mso-data-placement:same-cell;" />
Hackley School
</td>
<td>
1998
</td>
</tr>
<tr valign="top">
<td>
Bachelor of Science in Computer Science
<br style="mso-data-placement:same-cell;" />
Tufts University
</td>
<td>
2002
</td>
</tr>
</tbody>
</table>
</cfsavecontent>
<!--- Set header for file attachment. --->
<cfheader
name="content-disposition"
value="attachment; filename=data.xls"
/>
<!--- Stream the content. --->
<cfcontent
type="application/excel"
variable="#ToBinary( ToBase64( strData ) )#"
/>
@pravinmagar
Copy link

pravinmagar commented Oct 7, 2016

Hi bennadel,
Thanks for this article it helps me lot
Also I want to add horizontal line for that I did with hr that but that not work . is it possible for with hr tag or any other way to put horizontal line in same cell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment