When using addHTML, every block element in the HTML will be put in the next row. It would be nice to have an option to put all HTML in one cell only.
For example, when creating an Excel export of some data set, every row in the Excel sheet represents one row in the data set. If a field in the data set contains HTML, we want to have all HTML in one cell in the Excel output.
Please see this example:
$data = [
[
"col1 in row 1",
"<p>Row 1 sentence</p><p>Another row 1 sentence.</p>"
],
[
"col1 in row 2",
"<p>Row 2 sentence</p><p>Another row 2 sentence.</p>"
]
];
$xlsx = new CreateXlsx();
// row 1
$xlsx->addCell($data[0][0], 'A1');
$xlsx->addHtml($data[0][1], 'B1');
// row 2
$xlsx->addCell($data[1][0], 'A2');
$xlsx->addHtml($data[1][1], 'B2');
Problems:
- Cell B1 will contain "Row 1 sentence".
- Cell B2 will contain "Row 2 sentence"
- Cell B3 will contain "Another row 2 sentence."
In this case, it is preferred to replace the paragraph break in the HTML with a new line, so the complete contents of the HTML will appear in one cell.
This limits lay-out options (e.g. <h1> cannot be rendered as a Heading 1 cell), but that does not have to be a problem.