Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Html To Spreadsheet Bundle

Html To Spreadsheet Bundle Laravel Package

davidannebicque/html-to-spreadsheet-bundle

A Symfony bundle that converts annotated HTML tables into Excel, OpenDocument, or CSV files using declarative data-xls attributes. Style cells, add formulas, images, and multiple sheets with Twig and HTML instead of the PhpSpreadsheet API.

View on GitHub
Deep Wiki
Context7

This Symfony bundle converts annotated HTML tables into Excel (.xlsx), OpenDocument (.ods) and CSV files, letting you use Twig + HTML as a declarative spreadsheet DSL instead of the PhpSpreadsheet API. Mark up cells with data-xls-* attributes and render in one line using the SpreadsheetRenderer service or the SpreadsheetTrait in controllers.

  • Cell styling: background colors, font sizes, borders, and locking/protection
  • Formulas, freeze panes and column widths generated automatically
  • Images from local files, data-URIs or remote HTTP(S) URLs
  • Multiple sheets from multiple <table data-xls-sheet="..."> tags
  • Built-in French presets (money, date, float2, percent2) with optional strict mode
Frequently asked questions about Html To Spreadsheet Bundle
Can I use davidannebicque/html-to-spreadsheet-bundle in a Laravel application?
Not out of the box. The package is a Symfony bundle that relies on Symfony's dependency injection, bundle registration and Twig, none of which are native to Laravel. The HTML parsing and PhpSpreadsheet generation logic is fairly decoupled, so a Laravel wrapper is feasible: register the SpreadsheetRenderer in a service provider, swap Symfony's container for Laravel's, and replace Twig with Blade directives or a Twig adapter such as spatie/laravel-twig. Expect a proof-of-concept phase before committing to it in production.
How do I install the html-to-spreadsheet-bundle with Composer?
Run composer require davidannebicque/html-to-spreadsheet-bundle. In Symfony, enable it in config/bundles.php like any other bundle, then inject the SpreadsheetRenderer service or use the provided SpreadsheetTrait in your controller. In Laravel you would additionally need a custom service provider to bind the renderer, since auto-discovery of Symfony bundles does not apply.
What PHP, Symfony and PhpSpreadsheet versions does it require?
The package requires PHP 8.2 or higher and Symfony 6.4 or higher (6.4, 7.x and 8.x are listed as supported). PhpSpreadsheet 4.x and 5.x are supported, with 3.x possibly working but untested. Those constraints align with modern Laravel applications on PHP 8.2+, so the PhpSpreadsheet dependency itself should not conflict with packages like maatwebsite/excel.
How do the data-xls-* attributes actually work?
You annotate a normal HTML table with attributes such as data-xls-bg-color, data-xls-font-size, data-xls-border, data-xls-border-color and data-xls-locked, and the renderer maps each cell to the corresponding PhpSpreadsheet style or value. A single table can declare data-xls-sheet to become a named worksheet, and multiple tables produce multiple sheets. A strict mode makes invalid attributes throw an exception, which is useful for catching typos during development.
Can I use Blade templates instead of Twig with this bundle?
The bundle itself is Twig-oriented, so there is no built-in Blade integration. Because the mechanism is simply HTML attributes, plain Blade output works fine as long as you produce the same data-xls-* attributes in your markup. The gap is the Twig extension layer, so you would either use a Twig adapter in Laravel or reimplement the rendering entry point as a Blade directive or a service call.
Does it support multiple sheets, formulas, images and cell styling?
Yes. Each table with a data-xls-sheet attribute becomes its own worksheet, formulas are written into cells, and images can be embedded from local files, data URIs or remote HTTP/HTTPS URLs. Styling covers background colours, font sizes, borders, border colours, cell locking and protection, plus features like freeze panes and column widths. There are also built-in French-oriented presets such as money, date, float2 and percent2 for common number formats.
Can I export the same table to XLSX, ODS and CSV?
Yes, the renderer supports Excel (.xlsx), OpenDocument (.ods) and CSV output from the same annotated HTML source. You typically call the renderer once per format, or expose a format parameter in your route so users can pick the download type. CSV output is naturally limited compared to XLSX and ODS, since styles, images and multiple sheets have no meaningful CSV representation.
How does it perform with very large tables, for example 10,000+ rows?
Every row is parsed from HTML and then written through PhpSpreadsheet, so memory grows with table size and large exports can hit PHP memory limits. The bundle does not advertise dedicated streaming or chunking helpers, so for big reports you should raise memory limits, generate asynchronously via a queue, or fall back to writing PhpSpreadsheet directly in chunks. Benchmark with realistic data before relying on it for heavy reporting workloads.
Is this package production-ready and actively maintained?
The README labels it a first draft and work in progress, which means breaking changes between early releases are plausible. It is usable for internal reporting and exports, but pin the version in composer.json and check the GitHub issue tracker before upgrading. For anything business-critical, weigh the risk of the WIP status against the convenience of the declarative HTML syntax.
What are the alternatives if I only need Excel export in Laravel?
For pure CSV/XLSX generation without HTML templating, maatwebsite/excel or spatie/laravel-excel are the natural Laravel choices, since they integrate with Blade, queues and Laravel's container directly. Using PhpSpreadsheet on its own gives you full control with no Symfony or Twig layer, at the cost of writing the mapping logic yourself. This bundle makes sense mainly when you want HTML tables to act as the spreadsheet DSL and are comfortable adding a Symfony-to-Laravel adapter.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core