Read from one sheet and write to other

Topics: Developer Forum, User Forum
Oct 28, 2010 at 11:12 AM
Edited Oct 30, 2010 at 6:57 AM

Hi all,

     Is it possible in PHP Excel to read from a separate sheet and write to another.Let me make things clear.I want to read from a sheet which contain only one sheet and I want to write it in to another sheet which have multiple sheets.

Is this possible???

If yes, can you plz. illustrate with an example.


Thanks in advance,


Nov 1, 2010 at 11:48 PM
Edited Nov 1, 2010 at 11:51 PM

Perfectly possible: but how do you decide which worksheet in the book with multiple sheets you want to write to?

$firstBook = PHPExcel_IOFactory::load("workbook1.xls");
$secondBook = PHPExcel_IOFactory::load("workbook2.xls");
$cellValue = $firstBook->getActiveSheet()->getCell('A1')->getValue();
$cellValue = $firstBook->getActiveSheet()->getCell('A2')->getValue();
$cellValue = $firstBook->getActiveSheet()->getCell('A3')->getValue();
$cellValue = $firstBook->getActiveSheet()->getCell('A4')->getValue();