PHPEcel : erreur dès la compil

Topics: User Forum
Sep 30, 2009 at 10:45 AM
Edited Sep 30, 2009 at 10:49 AM

Bonjour,

Je n'ai pas encore réussi à faire fonctionner PHPExcel (version 1.7.0 Production).

voici le début de mon source :

<?php

set_include_path(get_include_path() . PATH_SEPARATOR . 'PHPExcel/');

/** PHPExcel */
include 'PHPExcel/IOFactory.php';

$objReader = PHPExcel_IOFactory::createReader('Excel2007');

....

 

ça plante avec  :

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homez.194/plaidoye/www/PHPExcel/IOFactory.php on line 61

Quelqu'un aurait-il une idée ?

merci d'avance

Alain


Coordinator
Sep 30, 2009 at 11:52 AM

I would only expect to see this error if you were still running PHP 4

Sep 30, 2009 at 12:44 PM

thanks for answering so quickly

After having changed some parameter in order to use PHP 5  this problem disappeared.

it happened only some minutes before

but now comes a new problem

my Excel file size is 5 MO

the load function aborts because of lack of memory

I understand that the whole file is put into RAM

It works if the file size is < 150 KO

Is it possible not to load the whole file into memory ?

 

 

Coordinator
Sep 30, 2009 at 1:07 PM
alains wrote:

my Excel file size is 5 MO

the load function aborts because of lack of memory

I understand that the whole file is put into RAM

It works if the file size is < 150 KO

Is it possible not to load the whole file into memory ?

The whole workbook is currently held in memory within the PHPExcel object... quite how much memory this actually takes is dependent on a range of factors including styles. We are looking at having some form of caching in the future so that different areas of the workbook can be swapped in and out of memory as they are required, but this possible solution will not be available for some time.

It is possible to read in only certain parts of the workbook using read filters, as described in section 6.2.1 of the developer ducumentation

 

Sep 30, 2009 at 1:59 PM

thank you

 

if I load only one sheet I have the following problem :

this sheet contains formulas refering to other sheets which are not loaded

-> the cells containing formulas have no more values

is it possible to do better ?

 

 

Developer
Sep 30, 2009 at 3:21 PM

How many sheets and cells to you have all together? Your workbook may be larger than what PHPExcel can handle at the moment.

Sep 30, 2009 at 4:04 PM

Thank you for your answer

my workbook may contain up to 240 sheets
the first sheet contains approximately 5000 cells

AS

 

Developer
Sep 30, 2009 at 4:15 PM

That would be more than 1,000,000 cells if all the sheets are that size. Well above what PHPExcel is able to handle. Would require more than 1GB memory.

Do you need the formulas or just the results? If you only need the results, then you can perhaps use

$cell->getOldCalculatedValue()

for formulas instead of

$cell->getValue()

If you load one sheet at a time each in one page request, then you might be able to extract all data. Right now that may be the only option.

Oct 2, 2009 at 1:10 PM

thank you for all

 

Oct 3, 2009 at 3:31 PM
Edited Oct 3, 2009 at 6:03 PM

it seems that with that big file and if I load only one sheet with  $objReader->setLoadSheetsOnly("mafeuille" );  before loading

I notice that if the sheet doesnt contain any formulas => no problem of RAM

else if the sheet contains formulas referring to other sheets  then appears the RAM problem

 

what do you think about it ?

 

 

Developer
Oct 3, 2009 at 10:09 PM

Can you say how many MB memory is being used? For sheets with and without formulas. Also how many cells/formulas are you reading this time?

Oct 4, 2009 at 6:39 AM

215 sheets

including :

210  containing 9 columns , 42 lines ,  72 formulas

3     containing 12 columns , 500 lines , 500 formulas