PHPReport icon indicating copy to clipboard operation
PHPReport copied to clipboard

how to make multisheet?

Open amin007 opened this issue 12 years ago • 2 comments

i have try https://github.com/vernes/PHPReport/wiki/Examples-with-templates this ok, but how i can make multisheet in excel template?

how i can manage array with one in multisheet...

amin007 avatar Jan 19 '13 02:01 amin007

Currently you can't create multisheet documents. But that option is on todo list.

vernes avatar Jan 20 '13 21:01 vernes

Thanks for your excellent job, vernes! As my expediency, simply make little change in "render" method as following. Please pay attention, this is only for "_usingTemplate" situation.

//create or generate report if ($this->_usingTemplate) { $sheets = $this->objPHPExcel->getAllSheets(); if(count($sheets) > 1){ foreach ($sheets as $sheet){ $this->objWorksheet = $sheet; $this->generateReport(); } } else{ $this->generateReport(); } } else { $this->createReport(); }

To reducing the unnecessary loops, I also add a parameter named "forSheet" to determine the current sheet. public function generateReport() { $this->_lastColumn=$this->objWorksheet->getHighestColumn();//TODO: better detection $this->_lastRow=$this->objWorksheet->getHighestRow(); foreach($this->_data as $data) { $forSheet = isset($data['forSheet']) ? $data['forSheet'] : null; $title = $this->objWorksheet->getTitle(); if(!empty($forSheet) && $forSheet != $title){ continue; } ... } ... }

yanhuixie avatar Apr 19 '15 06:04 yanhuixie