2017 © Pedro Peláez
 

library phpreport

Library for generating reports from PHP

image

nicolastavella/phpreport

Library for generating reports from PHP

  • Monday, October 23, 2017
  • by nicolastavella
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 45 Forks
  • 0 Open issues
  • 1 Versions
  • 55 % Grown

The README.md

PHPReport

PHPReport is a class for building and exporting reports from PHP. It's based on powerful PHPExcel library and includes exporting to popular formats such are HTML, Excel or PDF., (*1)

Features

  • Simple for using
  • Many ways to customize your input data
  • Build reports based on predefined templates
  • Export to HTML, Excel (xlsx and xls) and PDF

Installation

Install composer, and run composer update to install the required PHPExcel dependencies, (*2)

Usage and examples

Basicly, there are two way to build a report., (*3)

Building it "from scratch"

PHPReport does all the work, your just provide it with your data, like this:, (*4)

$R=new PHPReport();
$R->load(array(
            'id'=>'product',
            'data'=>array(
                        array('Some product',23.99),
                        array('Other product',5.25),
                        array('Third product',0.20)
                )
            )
        );

$R->render();

It's great for exporting tabular data. Input data can be further formatted, grouped and customized. See the wiki., (*5)

Building it from template

Template is usually some excel file, already formatted and with placeholders for data. There are two types of placeholders: static and dynamic. Static placeholders are, for example, some data like date, city or customer name. Dynamic placeholders are, for example, list of products with variable number of rows., (*6)

$R=new PHPReport(array('template'=>'invoice_template.xls'));
$R->load(array(
        array(
                'id'=>'invoice',
                'data'=>array(
                    'date'=>date('Y-m-d'),
                    'number'=>'000312',
                    'customer_id'=>'512',
                    'expiration_date'=>date('Y-m-d',strtotime('+30day')),
                    'name'=>'John Doe',
                    'company'=>'Example, inc',
                    'address'=>'Some address',
                    'city'=>'Gotham City',
                    'zip'=>'0123',
                    'phone'=>'+123456'
                ),
                'format'=>array(
                    'date'=>array('datetime'=>'d/m/Y'),
                    'expiration_date'=>array('datetime'=>'d/m/Y')
                )
            ),
        array(
                'id'=>'product',
                'data'=>array(
                    array('description'=>'Some product','price'=>23.99,'total'=>23.99),
                    array('description'=>'Other product','price'=>5.25,'total'=>2.25)
                ),
                'repeat'=>true,
                'format'=>array(
                    'price'=>array('number'=>array('prefix'=>'$','decimals'=>2)),
                    'total'=>array('number'=>array('prefix'=>'$','decimals'=>2))
                )
            )
        )
    );

$R->render();

These reports are great for complex exports like invoices. See the wiki for more examples., (*7)

The Versions

23/10 2017

dev-master

9999999-dev

Library for generating reports from PHP

  Sources   Download

LGPL

The Requires