I am using PHPExcel to generate reports for my application in cakephp.  The 
first worksheet is perfectly done but when I want to write on the same 
workbook different new worksheet, phpexcel just creates the worksheet but 
does not post data. For example record with id = 1 shows on its worksheet 
and id =2 shows on its worksheet...etc

Here is my code for my addsheet that inserts a new tab

    /**
    * Create new worksheet
    */
    public function createWorksheet() {
    $this->loadEssentials();
    $this->xls = new PHPExcel();
    }

    public function addSheet($tab) {
    $newWorksheet = new PHPExcel_Worksheet($this->xls, $tab);
    $this->xls->addSheet($newWorksheet);
    }
    
    //other code
    
    and here is my view for the worksheet

    <?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->addSheet($d['ItQuery']['id']);
    $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();
    ?>
    
Its my first time using the helper

I have posted this question on OS as well, hoping to get a quick response 
on this group - 
http://stackoverflow.com/questions/15501509/writing-data-into-a-new-worksheet-using-phpexcel-in-cakephp
  


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to