I'm using a product called "Aspose Cells" which allows me to generate an Excel workbook from HTML.
Recently, I wrote code to export a large table to Excel using Aspose Cells. I'm running into a problem where line breaks are stripped out of my cells.
So, the HTML may look like this in a browser:
Name | Address
-----+--------------
Bob | 123 Main St,
| Miami, FL
-----+--------------
Sue | 123 Broadway,
| New York NY
But when rendered by Aspose Cells, it looks like this:
Name | Address
-----+--------------
Bob | 123 Main St,Miami, FL
-----+--------------
Sue | 123 Broadway,New York NY
I have tried coding this several different ways. I have tried putting the street and city in different divs within a cell and I've tried putting a line break tag between them, but Aspose Cells seems to be ignoring the line break for some reason.
How do I make this table render with line breaks using Aspose Cells?
Update: Here's a snippet of code that will create a table like this:
html = "<table><tr><td>Bob</td><td>123 Main St,<br />Miami, FL</td></tr><tr><td>Sue</td><td>123 Broadway,<br />New York, NY</td></tr></table>";
Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense("Aspose.Total.lic");
var options = new HTMLLoadOptions(LoadFormat.Html);
byte[] data = Encoding.UTF8.GetBytes(html);
Workbook workbook;
using (MemoryStream ms1 = new MemoryStream(data))
{
workbook = new Workbook(ms1, options);
}
MemoryStream ms = new MemoryStream();
workbook.Save(ms, SaveFormat.Xlsx);
ms.Seek(0, SeekOrigin.Begin);
return ms;
tag has no end tag. In XHTML, the
tag must be properly closed, like this:
. W3Schools. So remove the closing tag from your breaks and try again. – cyboashu Jun 27 '16 at 18:28