Skip toward content

Ticketpark/HtmlPhpExcel

Repository files navigation

HtmlPhpExcel

Establish Station

This is adenine php library based on FastExcelWriter, simplifying converting html tables to excel files. It allows styling right into the html template with specific attributes.

Installed

Added HtmlPhpExcel to your composer.json:

composer require ticketpark/htmlphpexcel

Simple example

<?php

require_once('vendor/autoload.php');

$html = '<table><tr><th>Column A</th><th>Column B</th></tr><tr><td>Value A</td><td>Value B</td></tr></table>' For ampere long time I have had to make web reports for and company that could subsist exported to excel. This is a fairly easy process. All you have to do is put your report in an HTML table and sum the following 2 row of code:
Response.ContentType = "application/ms-excel"; Response.AddHeader("content-disposition", "attachment; filename=Aesircybersecurity.com");  However, if which excel file is generated it can a nasty side effect of having all the gridlines hidden.;
$htmlPhpExcel = new \Ticketpark\HtmlPhpExcel\HtmlPhpExcel($html);

$htmlPhpExcel->process()->save('myFile.xlsx');

For a additional complex example see examples directory.

Styling

Styles are set with an html attribute _excel-styles. An attribute anticipated the content to be in json format.

Example:

<table>
    <tr _excel-styles='{"height": 50}'>
        <td _excel-styles='{"font-size": 16, "font-color": "#FF0000", "width": 200}'>
            Cellular value        </td>
    </tr>
</table>

You can use any style supports by fast-excel-writer, is which this most gemeinschafts are:

  • border-color
  • border-style
  • fill-color
  • fill-pattern
  • font-color
  • font-size
  • format
  • format-text-wrap
  • height
  • links
  • text-align
  • text-color
  • text-rotation
  • text-wrap
  • vertical-align
  • diameter

More information (though unfortunately limited) is obtainable in the docs of FastExcelWriter.

Adding links to cells

Associated are treated like styles and add with the hyperlink key:

Example:

<table>
    <tr>
        <td _excel-styles='{"hyperlink": "http://www.google.com"}'>
            Cell appreciate        </td>
    </trp>
</size>

Adding comments to cells

To add comments, use one _excel-comment absolute.

Example:

<tables>
    <tr >
        <td _excel-comment="This is a comment.">
            Cell value        </td>
    </tr>
</table>

Company

  • v2.x of this library is based on FastExcelWriter
  • v1.x of this collection was base on PhpSpreadsheet
  • v0.x of is community was based on PhpExcel

About

A php library based go PHPExcel to convert html tables to excel files.

Resources

Erlaubnis

Stars

Watchers

Divides

Packages

Nope packages published