PHPackages                             starlight93/html-pdf-excel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. starlight93/html-pdf-excel

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

starlight93/html-pdf-excel
==========================

lightweight and fast library to render sheet-formatted-template to xlsx, pdf, and html easily. Really easy!

v1.0.3(1y ago)3149MITPHP

Since Aug 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/starlight93/php-html-pdf-excel)[ Packagist](https://packagist.org/packages/starlight93/html-pdf-excel)[ RSS](/packages/starlight93-html-pdf-excel/feed)WikiDiscussions development Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

HTML-PDF-EXCEL
--------------

[](#html-pdf-excel)

Thanks to [TCPDF](https://github.com/tecnickcom/TCPDF) and [PHPSpreadsheet](https://github.com/PHPOffice/PhpSpreadsheet). This library is a helper to generate html, pdf, and excel from excel-based template and array data.

[![Example](testing/example-design.png)](testing/example-design.png)

### Installation

[](#installation)

```
composer require starlight93/html-pdf-excel

```

### Usage

[](#usage)

```
//  your array of data, see: /testing/1data.json
$data = [
    'key'=>'value',
    'detail' => [
        [
            'key_detail1'   => 'value1',
            'amount'    => 2000
        ],[
            'key_detail1'   => 'value2',
            'amount'    => 1000
        ]
    ]
];

//  example: function to get string from a text file
public function getFromFile( $path ){
    $file = fopen( $path, "r" );
    $dt =  fread( $file ,filesize($path) ) ;
    fclose($file);
    return $dt;
}

//  your template string, see: /testing/1template.txt
$template = getFromFile(  "your text file path" );

$renderer = new \Starlight93\HtmlPdfExcel\Renderer;
//  if you want to try with /testing data dan template just pass true to Renderer Construct
// $renderer = new \Starlight93\HtmlPdfExcel\Renderer( true );
// with parameter true will take the data and template from /testing dir, so you can focus on config only

//  ======================= example rendering PDF start
$renderer->renderPDF(data: $data, template: $template, config: [
    'title' =>'testing',
    'break' => true,
    'left'  => 10,
    'top'   => 10,
    'right' => 12,
    'orientation'   =>'L',
    'size'  => [210, 297], // can be A4, F4, etc
    'fontSize'  => 10,
    'callback' => function( $pdf ){
        //  see tcpdf documentation for any available property and function
    },
    'header_callback' => function( $hd ){
        //  see tcpdf documentation for any available property and function
    },

    'footer_callback' => function( $ft ){
        //  see tcpdf documentation for any available property and function
    },
]);
//  ======================= end

//  ======================= example rendering XLS start
$renderer->renderXls(data: $data, template: $template, config: [
    'title' => 'testing',
    'break' => true, // to separate into
    'orientation'   =>'L',
    'size'  => 9, // see https://github.com/PHPOffice/PhpSpreadsheet/blob/master/src/PhpSpreadsheet/Worksheet/PageSetup.php
    'fontSize'  => 10
]);
//  ======================= end

//  ======================= example rendering XLS start
$renderer->renderHtml(data: $data, template: $template, config: [
    'title' =>'testing',
    // 'orientation'   =>'L',
    // 'size'  => 'A4',
    'fontSize'  => 10
]);
//  ======================= end
```

### Basic Syntax

[](#basic-syntax)

CodeDescriptionvtext verticalttext with no borderralign content to rightlalign content to leftcalign content to centerb**bold**hheader or column head+border all sides\[border left side\]border right side-border top side\_border bottom side=border doubled.number separator formatting, Example result: from 1000000 becomes 1.000.000w{number}%width {number} %. Example: w25% will set the column width to 25 % of table widthuunderlinei*italic*g[![#616469](https://camo.githubusercontent.com/9ca4c940b4a56b29a46ad4b061643e6d0413ed81bbf7fb24800ddde057ef4f3c/68747470733a2f2f7669612e706c616365686f6c6465722e636f6d2f31352f3631363436392f3030303030303f746578743d2b)](https://camo.githubusercontent.com/9ca4c940b4a56b29a46ad4b061643e6d0413ed81bbf7fb24800ddde057ef4f3c/68747470733a2f2f7669612e706c616365686f6c6465722e636f6d2f31352f3631363436392f3030303030303f746578743d2b) `gray background`y[![#e8ff17](https://camo.githubusercontent.com/8e479e0f000c724255a462f9281cde2fe424318887c2e12961e3a7d658d317cc/68747470733a2f2f7669612e706c616365686f6c6465722e636f6d2f31352f6538666631372f3030303030303f746578743d2b)](https://camo.githubusercontent.com/8e479e0f000c724255a462f9281cde2fe424318887c2e12961e3a7d658d317cc/68747470733a2f2f7669612e706c616365686f6c6465722e636f6d2f31352f6538666631372f3030303030303f746578743d2b) `yellow background`### Inside Looping Syntax

[](#inside-looping-syntax)

CodeDescription$dataIndexkey data index$detail.dataIndexdata index di detail?space or empty cell!grouping column and take the first cell value\_numberautonumberer starts from 1${looped\_array\_key}.{single\_array\_key}Set value given from key### Additional Features

[](#additional-features)

You can also use any mathematic formula to get dynamic value as the image above such as summary or etc.

### Dynamic Columns (table)

[](#dynamic-columns-table)

Below shows how to generate dynamic templates. Focus to *.dynamic* string which is shown in the picture

[![Example](testing/example-dynamic-design.png)](testing/example-dynamic-design.png)

```
//  your array of data for dynamic columns
$data = [
    'key'=>'value',
    'details' => [
        [
            'key_detail1'   => 'value1',
            'amount'    => 2000,
            'another1'    => 5000,
            'another2'    => 1000,
        ],[
            'key_detail1'   => 'value2',
            'amount'    => 1000,
            'amount'    => 2000,
            'another1'    => 2000,
            'another2'    => 4000
        ],[
            'key_detail1'   => 'value2',
            'amount'    => 1000,
            'amount'    => 2000,
            'another1'    => 3000,
            'another2'    => 2000
        ]
    ],

    // key below is to generate dynamic columns
    'dynamic' => [
        "Col Dynamic 1"=>"\$details.another1",
        "Col Dynamic 2"=>"\$details.another2",
    ]
];
```

By using data array above, the .dynamic header in the template will be replaced with the following dynamic key in the data array. So the final template result will be like this picture shown below:

[![Example](testing/example-dynamic-design-result.png)](testing/example-dynamic-design-result.png)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~234 days

Total

4

Last Release

661d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9cb446cdac2621d90e9d45cd7db6a49cbcba044da0bb6d2e1f85b15981ecb8b7?d=identicon)[starlight93](/maintainers/starlight93)

---

Top Contributors

[![starlight93](https://avatars.githubusercontent.com/u/4595828?v=4)](https://github.com/starlight93 "starlight93 (8 commits)")[![furatamasensei](https://avatars.githubusercontent.com/u/42239243?v=4)](https://github.com/furatamasensei "furatamasensei (1 commits)")

### Embed Badge

![Health badge](/badges/starlight93-html-pdf-excel/health.svg)

```
[![Health](https://phpackages.com/badges/starlight93-html-pdf-excel/health.svg)](https://phpackages.com/packages/starlight93-html-pdf-excel)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[spipu/html2pdf

Html2Pdf is a HTML to PDF converter written in PHP - It uses TCPDF - OFFICIAL PACKAGE

1.8k10.6M45](/packages/spipu-html2pdf)[elibyy/tcpdf-laravel

tcpdf support for Laravel 6, 7, 8, 9, 10, 11

3542.7M5](/packages/elibyy-tcpdf-laravel)[iio/libmergepdf

Library for merging multiple PDFs

40813.6M13](/packages/iio-libmergepdf)[creagia/laravel-sign-pad

Laravel package for of E-Signature with Signature Pad and Digital Certified Sign with TCPDF

54097.2k](/packages/creagia-laravel-sign-pad)[bfinlay/laravel-excel-seeder

Seed the database with Laravel using Excel, XLSX, XLS, CSV, ODS, Gnumeric, XML, HTML, SLK files

3944.4k](/packages/bfinlay-laravel-excel-seeder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
