Rewriting an Excel Document

Topics: Developer Forum, User Forum
Mar 2, 2009 at 11:57 PM
Edited Mar 2, 2009 at 11:57 PM

I just downloaded the latest PHPExcel and it's very impressive.  My problem is that I would like to write to an existing Excel document that has data already in it.  I want to place content into one (or more) cells in an existing Excel document without overwriting the file and losing the existing data.  I'm sure this can be done when the file is written but not sure how.  Can someone help?  Thanks a bunch!

Mar 3, 2009 at 2:07 AM
It should be possible to read, modify, write. Example:

$reader = PHPExcel_IOFactory::createReader('Excel2007');
$excel = $reader->load('template.xlsx');

$sheet = $excel->getSheet(0);

$writer = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');

Mar 3, 2009 at 12:47 PM
Thanks!  This worked great!