PHPExcel not saving my new sheet

I am using PHPExcel for create new sheet for an existing excel file with 3 sheets.

$newWorkSheet = new PHPExcel_Worksheet($objPHPExcel, 'filter');
$this->objPHPExcel->addSheet($newWorkSheet);

After calling $this->objPHPExcel->getSheetCount() it prints 4. But when I see the current excel file, there is not any new sheet.

Answers


You are forgetting the save part..

example..

$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));

Further Example in the official docs

http://phpexcel.codeplex.com/wikipage?title=Examples&referringTitle=Home


This is only creating an in-memory instance of the sheet. It will need to be written to disk.


Need Your Help

Instantiating error in Rails application

ruby-on-rails ruby-on-rails-3 model-view-controller controller instantiation

I am working on a Rails app, wherein I have two models, i.e. a chef model and a dish model.