定制 vulehd/phpreport 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vulehd/phpreport

Composer 安装命令:

composer require vulehd/phpreport

包简介

PHPReport

README 文档

README

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

It's based on PHPExcel, so download it and extract next to PHPReport.php file. To start using it, simply include PHPReport.php in your script and follow the documentation.

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:

$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.

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.

$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.

统计信息

  • 总下载量: 40
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 49
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL
  • 更新时间: 2015-06-17