A php library based on PHPExcel to convert html tables to Excel files, including styling.

Installs: 5 955

Dependents: 1

Suggesters: 0

Stars: 16

Watchers: 2

Forks: 9

Open Issues: 2

0.3.2 2015-06-25 20:53 UTC


This is a php library based on PHPExcel which simplifies converting html tables to excel files. It allows styling right within the html template with specific attributes.

Please note: This is a very early version of this library. Use on your own risk.


  • Write documentation for usage of table class, row class and cell class filtering.
  • Write documentation for usage of utf8EncodeValues() and utf8DecodeValues()


Add HtmlPhpExcel in your composer.json:

    "require": {
        "ticketpark/htmlphpexcel": "0.3.1"

Now tell composer to download the bundle by running the command:

$ php composer.phar update ticketpark/htmlphpexcel

Simple example



$html = '<table><tr><th>Column A</th><th>Column B</th></tr><tr><td>Value A</td><td>Value B</td></tr></table>';
$htmlPhpExcel = new \Ticketpark\HtmlPhpExcel\HtmlPhpExcel($html);

// Create and output the excel file to the browser

// Alternatively create the excel and save to a file

// or get the PHPExcel object to do further work with it
$phpExcelObject = $htmlPhpExcel->process()->getExcelObject();

For a more complex example with styling options see example directory.


There is support for specific html attributes to allow styling of the excel output. The attributes expect the content to be json_encoded.

  • _excel-styles
    Supports everything which is possible with PHPExcel's applyFromArray() method (also see here).


        <td _excel-styles='{"font":{"size":16,"color":{"rgb":"FF0000"}}}'>Foo</td>
  • _excel-dimensions
    Supports changing dimensions of rows (when applied to a <tr> or <td>) or column (when applied to a <td>),


    <tr _excel-dimensions='{"row":{"rowHeight":50}}'>
        <td _excel-dimensions='{"column":{"width":20}}'>Foo</td>
  • _excel-explicit
    Supports applying an explicit cell value type.


        <td _excel-explicit='PHPExcel_Cell_DataType::TYPE_STRING'>0022</td>


This bundle is under the MIT license. See the complete license in the bundle: