How to generate reports with records showing in different tabs

Mar 19, 2013 at 3:15 PM
I am using PHPExcel Helper to generate reports for my application. What i would like to do is that the report output should created per tab. For example record with id = 1 shows on its tab and id =2 shows on its tab...etc

Here is my code i am using to echo results in the view
<?php
$this->PhpExcel->createWorksheet();
$this->PhpExcel->setDefaultFont('Calibri', 12);

// define table cells
$table = array(
array('label' => __('id'), 'width' => 'auto', 'filter' => true),
array('label' => __('name'), 'width' => 'auto', 'filter' => true),
array('label' => __('type'), 'width' => 'auto', 'filter' => true),
array('label' => __('comment'), 'width' => 'auto', 'filter' => true),
array('label' => __('status type'), 'width' => 'auto', 'filter' => true),
array('label' => __('created'), 'width' => 'auto', 'filter' => true),
);

// heading
$this->PhpExcel->addTableHeader($table, array('name' => 'Cambria', 'bold' => true));

foreach ($itQueries as $d) {
$this->PhpExcel->addTableRow(array(
$d['ItQuery']['id'],
$d['ItQuery']['hr_employee_id'],
$d['ItQuery']['it_query_type_id'],
$d['ItQuery']['comment'],
$d['ItQuery']['status_type'],
$d['ItQuery']['created'],
));
}

$this->PhpExcel->addTableFooter();
$this->PhpExcel->output();
$this->PhpExcel->exit();
?>
and here is code for my PHPExcelHelper
/**
* Create new worksheet
*/
public function createWorksheet() {
$this->loadEssentials();
$this->xls = new PHPExcel();
}


/**
* Set default font
*/
public function setDefaultFont($name, $size) {
$this->xls->getDefaultStyle()->getFont()->setName($name);
$this->xls->getDefaultStyle()->getFont()->setSize($size);
}


public function addTableHeader($data, $params = array()) {
// offset
if (array_key_exists('offset', $params))
$offset = is_numeric($params['offset']) ? (int)$params['offset'] : PHPExcel_Cell::columnIndexFromString($params['offset']);
// font name
if (array_key_exists('font', $params))
$this->xls->getActiveSheet()->getStyle($this->row)->getFont()->setName($params['font_name']);
// font size
if (array_key_exists('size', $params))
$this->xls->getActiveSheet()->getStyle($this->row)->getFont()->setSize($params['font_size']);
// bold
if (array_key_exists('bold', $params))
$this->xls->getActiveSheet()->getStyle($this->row)->getFont()->setBold($params['bold']);
// italic
if (array_key_exists('italic', $params))
$this->xls->getActiveSheet()->getStyle($this->row)->getFont()->setItalic($params['italic']);

//OTHER CODE
Its my first time using the helper
Mar 19, 2013 at 6:30 PM
This is the codeplex site discussion board. The PHPExcel discussion board can be found here.