PHP Classes

PHP Report: Generate Excel, HTML, PDF reports from data arrays

Recommend this page to a friend!

  Author Author  
Picture of verni
Name: verni <contact>
Classes: 1 package by
Country: Bosnia and Herzegovina Bosnia and Herzegovina
Age: 38
All time rank: 3472 in Bosnia and Herzegovina Bosnia and Herzegovina
Week rank: 43 Up1 in Bosnia and Herzegovina Bosnia and Herzegovina Up


  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
This class can generate reports in Excel, HTML and PDF formats from arrays of data.

It takes arrays of data that define the contents and format of cells of a spreadsheet and it generates an spreadsheet file using the PHPExcel package in several formats like Excel, HTML and PDF.

The class allows defining the content and format of header and footer cells, alignment and width for different groups of cells, define groups of cells, etc..

Details

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.

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

Usage and examples

Basicly, there are two way to build a report.

Building it "from scratch"

PHPReport does all the work, your just provide it with your data, like this: <pre> $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(); </pre>

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

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.

<pre> $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(); </pre>

These reports are great for complex exports like invoices. See the wiki for more examples.


  Classes of verni  >  PHP Report  >  Download Download .zip .tar.gz  >  Support forum Support forum (14)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP Report
Base name: php-report
Description: Generate Excel, HTML, PDF reports from data arrays
Version: 1.12
PHP version: 5.2
License: GNU Lesser General Public License (LGPL)
All time users: 7685 users
All time rank: 232
Week users: 3 users
Week rank: 34 Up
 
  Groups   Screenshots Screenshots   Rate classes User ratings  
  Applications   Related pages   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Files and Folders Listing, accessing and manipulating files and folders View top rated classes

  Files folder image Screenshots  
/opt2/mlemos/httpd/htdocs/application/repository_browse.php 2939 phpreport_example.png
File Role Description
Accessible without login Image file phpreport_example.png Screen Simple generation of report from excel template


  User ratings  
RatingsUtility Consistency Documentation Examples Tests Videos Overall Rank
All time: Good (97%) Good (91%) Sufficient (72%) Good (86%) - - Sufficient (73%) 199
Month: Not yet rated by the users

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.


  Related pages  
Latest version and examples

  Files folder image Files  
File Role Description
Files folder imageexamples (10 files)
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file Advanced_examples.txt Doc. Some examples with templates
Accessible without login Plain text file Examples.txt Doc. Some examples
Accessible without login Plain text file composer.json Data Auxiliary data
Plain text file PHPReport.php Class Class source

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file example_1.php Example Example script
  Accessible without login Plain text file example_10.php Example Example script
  Accessible without login Plain text file example_2.php Example Example script
  Accessible without login Plain text file example_3.php Example Example script
  Accessible without login Plain text file example_4.php Example Example script
  Accessible without login Plain text file example_5.php Example Example script
  Accessible without login Plain text file example_6.php Example Example script
  Accessible without login Plain text file example_7.php Example Example script
  Accessible without login Plain text file example_8.php Example Example script
  Accessible without login Plain text file example_9.php Example Example script

Install with Composer Install with Composer - Download Download all files: php-report.tar.gz php-report.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
File Role Description
Files folder imageexamples (10 files)
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file Advanced_examples.txt Doc. Some examples with templates
Accessible without login Plain text file Examples.txt Doc. Some examples
Accessible without login Plain text file composer.json Data Auxiliary data
Plain text file PHPReport.php Class Class source

  Files folder image Files  /  examples  
File Role Description
  Accessible without login Plain text file example_1.php Example Example script
  Accessible without login Plain text file example_10.php Example Example script
  Accessible without login Plain text file example_2.php Example Example script
  Accessible without login Plain text file example_3.php Example Example script
  Accessible without login Plain text file example_4.php Example Example script
  Accessible without login Plain text file example_5.php Example Example script
  Accessible without login Plain text file example_6.php Example Example script
  Accessible without login Plain text file example_7.php Example Example script
  Accessible without login Plain text file example_8.php Example Example script
  Accessible without login Plain text file example_9.php Example Example script

Install with Composer Install with Composer - Download Download all files: php-report.tar.gz php-report.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.