Download the PHP package davidannebicque/html-to-spreadsheet-bundle without Composer
On this page you can find all versions of the php package davidannebicque/html-to-spreadsheet-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download davidannebicque/html-to-spreadsheet-bundle
More information about davidannebicque/html-to-spreadsheet-bundle
Files in davidannebicque/html-to-spreadsheet-bundle
Package html-to-spreadsheet-bundle
Short Description A Symfony bundle to convert HTML tables to Excel spreadsheets using PhpSpreadsheet.
License MIT
Informations about the package html-to-spreadsheet-bundle
HtmlToSpreadsheetBundle
Warning
First draft of a Symfony bundle to convert HTML tables into Excel (.xlsx), OpenDocument (.ods) or CSV. WIP.
Convert annotated HTML tables into Excel (.xlsx), OpenDocument (.ods) or CSV using a simple, declarative syntax.
This bundle is ideal for developers who want to use Twig + HTML as a DSL to build spreadsheets, without directly using the PhpSpreadsheet API.
Requirements
- PHP 8.2+
- Symfony 6.4+
- PhpSpreadsheet 4.x|5.x (maybe 3 also compatible, not tested)
Features
- Write spreadsheets using HTML tables and
data-xls-*attributes - One-liner rendering with
SpreadsheetRendererservice orSpreadsheetTraitfor controllers - Auto-generation of Excel sheets, styles, formulas, freezepanes, column widths, images, etc.
- Built-in French-oriented presets (
money,date,float2,percent2, etc.) - Generate XLSX, ODS, CSV with multi-format export support
- Cell styling (background colors, font sizes, borders, protection)
- Image support (local files, data-URI, remote HTTP/HTTPS URLs)
- Multiple sheets from multiple
<table data-xls-sheet="...">tags - Strict mode (invalid attributes → exception)
- Fully extensible (register custom styles, validators, etc.)
Cell Styling Attributes
Background & Font
data-xls-bg-color="#FF0000"- Set cell background color (hex format)data-xls-font-size="14"- Set font size (numeric value)
Borders
data-xls-border="thin"- Set border style (thin,medium,thick,none)data-xls-border-color="#000000"- Set border color (hex format)
Cell Protection
data-xls-locked="true"- Lock cell (requires sheet protection)data-xls-locked="false"- Unlock cell for editing
Example
Cell Merging
Merge cells horizontally (colspan) or vertically (rowspan), or both simultaneously.
Attributes
data-xls-colspan="N"- Merge N columns horizontallydata-xls-rowspan="N"- Merge N rows vertically
Examples
Horizontal Merging (Colspan):
Vertical Merging (Rowspan):
Combined Merging:
Complex Table Example:
Combining with Styling
Merged cells can be styled like any other cell:
Font Styling
Control font appearance with these attributes:
Font Color & Weight
data-xls-font-color="#FF0000"- Set font color (hex format)data-xls-font-bold="true"- Make text bold (trueorfalse)data-xls-font-italic="true"- Make text italic (trueorfalse)
Font Decoration & Family
data-xls-font-underline="single"- Underline text (single,double, ornone)data-xls-font-name="Arial"- Set font family (e.g., "Arial", "Times New Roman", "Calibri")
Example
Conditional Formatting
Apply dynamic formatting based on cell values using a simple syntax:
Syntax: data-xls-conditional="condition|style1|style2..."
Available Conditions
value>X- Greater thanvalue<X- Less thanvalue>=X- Greater than or equalvalue<=X- Less than or equalvalue==X- Equal tovalue!=X- Not equal tobetween:min:max- Value between min and max
Available Styles
bg:RRGGBB- Background color (hex without #)font:RRGGBB- Font color (hex without #)bold- Bold text
Examples
Auto-size Columns
Automatically adjust column widths to fit content. This feature uses PhpSpreadsheet's auto-sizing capability to calculate optimal column widths based on cell content.
Attributes
Table-level:
data-xls-autosize="true"- Auto-size all columns in the tabledata-xls-autosize="A"- Auto-size a single column (A)data-xls-autosize="A:D"- Auto-size a range of columns (A through D)data-xls-autosize="A,C,E"- Auto-size specific columns (A, C, and E)
Column-level (in <colgroup>):
data-xls-autosize="true"- Auto-size this specific column
Examples
Auto-size all columns:
Auto-size specific columns:
Auto-size columns by range:
Column-level auto-size with colgroup: html
html <td data-xls-comment="Please verify this value" data-xls-comment-author="John Doe"> 1,234.56 html <td data-xls-comment="This is a longer comment that requires more space to display properly" data-xls-comment-width="300" data-xls-comment-height="100"> Complex data html <td data-xls-comment="IMPORTANT: Read this first" data-xls-comment-visible="true"> Critical value html
html
<td data-xls-image="/path/to/image.png" data-xls-img-width="100" data-xls-img-height="50">
html
html
html
html <td data-xls-link="https://symfony.com/doc" data-xls-link-tooltip="Click to view Symfony documentation"> Symfony Docs html <td data-xls-link="https://example.com" data-xls-bg-color="#FFFFCC" data-xls-font-bold="true" data-xls-link-tooltip="Important link"> Highlighted Link bash composer require davidannebicque/html-to-spreadsheet-bundle yaml html_to_spreadsheet: strict: true include_builtins: true yaml html_to_spreadsheet: default_styles: mon_style: font: bold: true color: 'FF0000' alignment: horizontal: 'center' twig {# templates/test/export.html.twig #}
| Nom | Prénom | Date | Montant (€) |
|---|---|---|---|
| {{ l.nom }} | {{ l.prenom }} | {# Date formatée #}{{ l.date|date('Y-m-d') }} | {# Montant format monétaire #}{{ l.montant }} |
| Total : |
| # | Nom | Prénom | Date brute | Montant brut |
|---|---|---|---|---|
| {{ loop.index }} | {{ l.nom }} | {{ l.prenom }} | {{ l.date|date('Y-m-d H:i') }} | {{ l.montant }} |
All versions of html-to-spreadsheet-bundle with dependencies
symfony/dependency-injection Version ^6.4 || ^7.0 || ^8.0
symfony/framework-bundle Version ^6.4 || ^7.0 || ^8.0
symfony/config Version ^6.4 || ^7.0 || ^8.0
symfony/http-foundation Version ^6.4 || ^7.0 || ^8.0
symfony/console Version ^6.4 || ^7.0 || ^8.0
symfony/twig-bundle Version ^6.4 || ^7.0 || ^8.0
ext-dom Version *
ext-libxml Version *