Append Content in existing excel file

Topics: Developer Forum
Feb 3, 2010 at 12:14 PM

Hi All,

 

I am pretty new to PHPExcel. So far i have created a excel and eventually writing content inside file using following code

 

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save("demo.xls");
					

but every time i execute this code again it is not appending the content inside an  excel file though everytime i chagne the

cell position.

 

so could anyone help me how can i append content in an existing excel file

 

Thanks,

nihar

 

Coordinator
Feb 3, 2010 at 3:48 PM
$objPHPExcel = PHPExcel_IOFactory::load("demo.xls");
$maxRow = $objPHPExcel->getActiveSheet()->getHighestRow() + 1;
$objPHPExcel->getActiveSheet()->setCellValue('A'.$maxRow,'New Value'); 
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save("demo.xls");