Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to make multisheet? #3

Open
amin007 opened this issue Jan 19, 2013 · 2 comments
Open

how to make multisheet? #3

amin007 opened this issue Jan 19, 2013 · 2 comments

Comments

@amin007
Copy link

amin007 commented Jan 19, 2013

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

@vernes
Copy link
Owner

vernes commented Jan 20, 2013

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

@yanhuixie
Copy link

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;
}
...
}
...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants