problem with reader of excel5

Topics: Developer Forum, User Forum
Sep 24, 2008 at 4:56 PM
hi all,

    i am using
$objReader = new PHPExcel_Reader_Excel5();
$objPHPExcel = $objReader->load(SGL_MOD_DIR . "/sample/classes/Sample.xls");
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objPHPExcel->getActiveSheet()->setCellValue('C9', 'Sample Order');//test if i can edit

but it seems the image in the original file is missing.

Sep 24, 2008 at 5:15 PM
I'm afraid that PHPExcel_Reader_Excel5 is currently not reading images, but the problem has been addressed. There are still a couple of hurdles.

If you need this feature for spreadsheet manipulation from template, the solution for you may be to use Excel 2007 template instead of Excel 2003 template. Convert your Sample.xls to Sample.xlsx using MS Office Excel 2007 or MS Office Excel 2003 with SP3 + compatibility pack. PHPExcel_Writer_Excel5 supports images so you can still create xls files with images.

Related discussion (reading Excel 2007 files with images):
Sep 25, 2008 at 11:54 AM
got it.thanks very much.

i have one more related question:

will the page setting be kept after load(i mean excel5)?
it seems both image and page setting is missgin when i read from xls and save as xls.

Sep 25, 2008 at 12:03 PM
PHPExcel_Reader_Excel5 does recognize a good deal of page setup properties. This includes paper size, orientation, page margins, header / footer etc. But these features were added recently so to get this working you will need to latest source of PHPExcel (1.6.3 won't do).
Download latest source from here:
Sep 25, 2008 at 12:24 PM
I have get a lastest version,thanks!

Can the xlsx template work like php template tech,that we put some tag in the template file,
and it then will be merged with variable data?

thanks for your reply!!

Sep 25, 2008 at 12:53 PM
It may not be that hard to get what you want.


// 2007-read.xlsx contains cells where one has typed "tags" [CUSTOMER_NAME] or [EMAIL]
$customerName = 'John Smith';
$email = '';

$objReader = new PHPExcel_Reader_Excel2007();
$PHPExcel = 
$ws = $PHPExcel->getActiveSheet();

foreach ($ws->getCellCollection() as $cell) {
    switch ($cell->getValue()) {
    case '[CUSTOMER_NAME]':
    case '[EMAIL]':

$objWriter = new PHPExcel_Writer_Excel2007($PHPExcel);