Namal
Namal

Reputation: 2071

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.

Upvotes: 0

Views: 248

Answers (2)

Oliver M Grech
Oliver M Grech

Reputation: 3171

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

Upvotes: 1

Scary Wombat
Scary Wombat

Reputation: 44834

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

Upvotes: 1

Related Questions