load file, write and save

Topics: Developer Forum
Nov 30, 2010 at 11:52 AM

Hello,

Is this possible, in Phpexcel to load xls file, write to the same file some information, and save it as another xls? If yes, can you put some example?

 

Thanks, 

pan_slaw

Coordinator
Nov 30, 2010 at 9:52 PM

Yes

/** Include PHPExcel */
require_once '../Classes/PHPExcel/IOFactory.php';
// load the file inputTest.xls
$objPHPExcel = PHPExcel_IOFactory::load("inputTest.xls");
// make your changes to the file
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Hello') 
                              ->setCellValue('B1', 'World!');
// save the file outputTest.xls
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('outputTest.xls');

Dec 1, 2010 at 11:01 AM

wow, great!! 

Thanks!