HTML and CSS
phpxlsx can transform HTML and CSS to create new contents.
addHtml is the method to add HTML:
This method includes the following parameters:
- $html: HTML/CSS to transform
- $position: cell position in the active sheet (A1, C3, AB7...)
- $options: array to set extra options
XLSX spreadsheets don't support the same contents and styles that can be added with DOCX documents. XLSX supports a limited content types and styles when transforming HTML and CSS. On the addHtml API page are detailed the supported contents and styles.
Each new release of phpxlsx includes support for new contents and styles when transforming HTML and CSS.
When inserting HTML contents, a whole cell position is filled when transforming block contents such as paragrahs, headings or links. Multiple span tags can be added in the same cell position. Each new block content is created after the previous cell position.
The following code adds a HTML content applying CSS styles:
Install and enable Tidy and mbstring PHP extensions to transform HTML.