Losing formula from template

Topics: Developer Forum
Jun 26, 2009 at 1:34 PM

Hello Everybody,

I'm loading a template (.xls), I fill some information in the field and safe it ( .xlsx)

There are some formula's in de worksheets from the template. But in som cell's I lose the formula's while in other they stay.

Does someone know why that happen and how I can fix it?




Jun 26, 2009 at 9:59 PM

What do the formulas look like that are lost?

Can you check that the formulas are read ok by the reader. For example, if cell A1 contains a formula =2*B1, try to verify that it has been read properly by dumping the value.

$reader = PHPExcel_IOFactory::createReader('Excel5');
$excel = $reader->load('read.xls');

$sheet = $excel->getActiveSheet();
var_dump($sheet->getCell('A1')->getValue()); // string(5) "=2*B1"

Jul 15, 2009 at 2:43 PM


I forgot to reply.

If you do a var_dump or print_r you get an recursive loop with information. Somethimes I went on the way I want an other cells lose there information.



Jul 15, 2009 at 3:42 PM

I'm afraid I would have to see the Excel file. Can you send it to: erik at phpexcel dot net.

Jul 18, 2009 at 2:16 AM

[File received]

You are right. It turns out the reason is Excel5 reader not recognizing shared formulas. Has now been solved: