linodh linodh - 17 days ago 6
HTML Question

In an HTML Saved as xls; how to acheive ALT+Enter Equivalent in html(new line inside a cell)

Hi I have legacy implementation of the spreadsheet import from a gridview and it is as follows
Html representation of the DataTable result set is written onto the HttpResponse stream with content-disposition header set to an xls file (i.e content-disposition=attachment; filename=abcd.xls)

The html tables will intern becomes spreadsheet table. I have a certain set of data in the following format



<table style="border: 1x solid black;">
<tr>
<th>Id</th>
<th>Name</th>
<th>Items</th>
</tr>

<tr>
<td>1</td>
<td>A</td>
<td>
<ul>
<li>item 1</li>
<li>item2</li>
<li>item 3</li>
</ul>
</td>
</tr>
<tr>
<td>2</td>
<td>B</td>
<td>
<ul>
<li>item 1</li>
<li>item2</li>
</ul>
</td>
</tr>
</table>





I was expecting spreadsheet to show 2 rows with Items Column showing un-ordered list inside cell. Instead the excel shows up 5 rows (3 rows for Name A and 2 rows for Name B).

In a normal spreadsheet cell we can use ALT+Enter keyword to add new lines inside a cell, Is there a html encode character that tells the xls file to mimic the ALT+Enter action?

I had tried
<br/>
, Line feed character 10 and Carriage Return 13 with no luck

Answer
<td>
    item 1<br style="mso-data-placement:same-cell;" />
    item 2<br style="mso-data-placement:same-cell;" />
    item 3
</td>