Example #1
0
<?php

include '../PHPReport.php';
$R = new PHPReport();
$R->load(array('id' => 'product', 'data' => array(array('Some product', 23.99, 12), array('Other product', 5.25, 2.25), array('Third product', 0.2, 3.5))));
echo $R->render();
exit;
Example #2
0
<?php

include '../PHPReport.php';
$R = new PHPReport();
$R->load(array('id' => 'product', 'header' => array('product' => 'Product name', 'price' => 'Price', 'tax' => 'Tax'), 'footer' => array('product' => '', 'price' => 28.54, 'tax' => 17.89), 'config' => array('header' => array('product' => array('width' => 120, 'align' => 'center'), 'price' => array('width' => 80, 'align' => 'center'), 'tax' => array('width' => 80, 'align' => 'center')), 'data' => array('product' => array('align' => 'left'), 'price' => array('align' => 'right'), 'tax' => array('align' => 'right')), 'footer' => array('price' => array('align' => 'right'), 'tax' => array('align' => 'right'))), 'data' => array(array('product' => 'Some product', 'price' => 23.99, 'tax' => 12), array('product' => 'Other product', 'price' => 5.25, 'tax' => 2.25), array('product' => 'Third product', 'price' => 0.2, 'tax' => 3.5)), 'group' => array('caption' => array('cat1' => 'Category 1', 'cat2' => 'Another category'), 'rows' => array('cat1' => array(0), 'cat2' => array(1, 2)), 'summary' => array('cat1' => array('product' => '', 'price' => 23.99, 'tax' => 12), 'cat2' => array('product' => '', 'price' => 5.45, 'tax' => 5.75))), 'format' => array('price' => array('number' => array('prefix' => '$', 'decimals' => 2)), 'tax' => array('number' => array('sufix' => ' EUR', 'decimals' => 1)))));
echo $R->render('excel');
exit;
Example #3
0
    $template = $_GET['template'];
} else {
    $template = 'stats.xls';
}
//set absolute path to directory with template files
$templateDir = 'C:\\Ampps\\www\\PHPReport\\examples\\template\\';
//we get some data, e.g. from database
//function generates some random data
function getData($n = 1, $cols = array('A'), $rows = 1, $c = array('Some country'))
{
    //data is an array with 34 elements for each row!
    $data = array();
    for ($i = 1; $i <= $n; $i++) {
        $d['country'] = $c[$i - 1];
        foreach ($cols as $col) {
            for ($r = 1; $r <= $rows; $r++) {
                $d[$col . $r] = rand(0, 20);
            }
        }
        $data[] = $d;
    }
    return $data;
}
$data = getData(3, array('A', 'B', 'C'), 11, array('Italy', 'Germany', 'France'));
//set config for report
$config = array('template' => $template, 'templateDir' => $templateDir);
$R = new PHPReport($config);
$R->load(array('id' => 'v', 'repeat' => true, 'data' => $data));
$R->setHeading('Report: Visitors in January');
echo $R->render('html');
exit;
Example #4
-1
<?php

include '../PHPReport.php';
$R = new PHPReport();
$R->load(array('id' => 'product', 'header' => array('Product name', 'Price', 'Tax'), 'footer' => array('', 28.54, 17.89), 'config' => array(0 => array('width' => 120, 'align' => 'left'), 1 => array('width' => 80, 'align' => 'right'), 2 => array('width' => 80, 'align' => 'right')), 'data' => array(array('Some product', 23.99, 12), array('Other product', 5.25, 2.25), array('Third product', 0.2, 3.5)), 'format' => array(1 => array('number' => array('prefix' => '$', 'decimals' => 2)), 2 => array('number' => array('sufix' => ' EUR', 'decimals' => 1)))));
echo $R->render();
exit;
Example #5
-1
<?php

include '../PHPReport.php';
$R = new PHPReport();
$R->load(array('id' => 'product', 'header' => array('product' => 'Product name', 'price' => 'Price', 'tax' => 'Tax'), 'footer' => array('product' => '', 'price' => 28.54, 'tax' => 17.89), 'config' => array('header' => array('product' => array('width' => 120, 'align' => 'center'), 'price' => array('width' => 80, 'align' => 'center'), 'tax' => array('width' => 80, 'align' => 'center')), 'data' => array('product' => array('align' => 'left'), 'price' => array('align' => 'right'), 'tax' => array('align' => 'right')), 'footer' => array('price' => array('align' => 'right'), 'tax' => array('align' => 'right'))), 'data' => array(array('product' => 'Some product', 'price' => 23.99, 'tax' => 12), array('product' => 'Other product', 'price' => 5.25, 'tax' => 2.25), array('product' => 'Third product', 'price' => 0.2, 'tax' => 3.5)), 'format' => array('price' => array('number' => array('prefix' => '$', 'decimals' => 2)), 'tax' => array('number' => array('sufix' => ' EUR', 'decimals' => 1)))));
echo $R->render();
exit;
Example #6
-1
<?php

include '../PHPReport.php';
$R = new PHPReport();
$R->load(array(array('id' => 'product', 'data' => array(array('Some product', 23.99, 12), array('Other product', 5.25, 2.25), array('Third product', 0.2, 3.5))), array('id' => 'product2', 'data' => array(array('value1', 'value2', 'value3', 'value4'), array('value5', 'value6', 'value7', 'value8')))));
echo $R->render();
exit;
Example #7
-1
<?php

include '../PHPReport.php';
//which template to use
if (isset($_GET['template'])) {
    $template = $_GET['template'];
} else {
    $template = 'invoice.xls';
}
//set absolute path to directory with template files
$templateDir = 'C:\\Ampps\\www\\PHPReport\\examples\\template\\';
//we get some products, e.g. from database
$products = array(array('description' => 'Example product', 'qty' => 2, 'price' => 4.5, 'total' => 9), array('description' => 'Another product', 'qty' => 1, 'price' => 13.9, 'total' => 13.9), array('description' => 'Super product!', 'qty' => 3, 'price' => 1.5, 'total' => 4.5), array('description' => 'Yet another great product', 'qty' => 2, 'price' => 10.8, 'total' => 21.6), array('description' => 'Awesome', 'qty' => 1, 'price' => 19.9, 'total' => 19.9));
//set config for report
$config = array('template' => $template, 'templateDir' => $templateDir);
$R = new PHPReport($config);
$R->load(array(array('id' => 'inv', 'data' => array('date' => date('Y-m-d'), 'number' => 312, 'customerid' => 12, 'orderid' => 517, 'company' => 'Example Inc.', 'address' => 'Some address', 'city' => 'Some City, 1122', 'phone' => '+111222333'), 'format' => array('date' => array('datetime' => 'd/m/Y'))), array('id' => 'prod', 'repeat' => true, 'data' => $products, 'minRows' => 2, 'format' => array('price' => array('number' => array('prefix' => '$', 'decimals' => 2)), 'total' => array('number' => array('prefix' => '$', 'decimals' => 2)))), array('id' => 'total', 'data' => array('price' => 68.90000000000001), 'format' => array('price' => array('number' => array('prefix' => '$', 'decimals' => 2))))));
echo $R->render('html');
exit;
Example #8
-1
<?php

include '../PHPReport.php';
$R = new PHPReport();
$R->load(array('id' => 'product', 'data' => array(array('Some product', 23.99, 12), array('Other product', 5.25, 2.25), array('Third product', 0.2, 3.5)), 'format' => array(1 => array('number' => array('prefix' => '$', 'decimals' => 2)), 2 => array('number' => array('sufix' => ' EUR', 'decimals' => 1)))));
echo $R->render();
exit;