Can't load xlsx file

Topics: Developer Forum, Project Management Forum, User Forum
Jun 3, 2011 at 8:53 PM


The loading of rap.xlsx is not working :

require_once '/var/www/htdocs/rapport/Classes/PHPExcel/IOFactory.php';

$objet1 = new PHPExcel_Reader_Excel5();
$excel1 = $objet1->load('rap.xlsx');
$objet2 = new PHPExcel_Reader_Excel5();
$excel2 = $objet2->load('rap2.xlsx');

$writer = new PHPExcel();

for ($i=0;$i<$excel1->getSheetCount();$i++){

for ($i=0;$i<$excel2->getSheetCount();$i++){

$save = new PHPExcel_Writer_Excel5($writer);

Can anyone help me?


Jun 3, 2011 at 8:58 PM

Try using the correct reader... the Excel5 reader is for Excel BIFF files, those files (typically) created using MS Excel 2003 or earlier, with an extension of .xls. To load Office Open XML files created with Excel 2007 or later, with an extension of .xlsx, you need to use the Excel2007 Reader.

Likewise, when writing, use the correct writer: Excel2007 for .xlsx files, Excel5 for .xls files.

Jun 6, 2011 at 3:45 PM

Thanks MarkBaker !

I have a new error : Fatal error: Class 'ZipArchive' not found in /var/www/htdocs/rapport/Classes/PHPExcel/Reader/Excel2007.php on line 368

I'm looking at this huge file trying to find a clue...

Jun 6, 2011 at 9:09 PM

From the Requirements for PHPExcel:

  • PHP extension php_zip enabled
  • Jun 9, 2011 at 6:02 PM

    Finally i used this :

    // Creation d'un lecteur
    $objReader = PHPExcel_IOFactory::createReader($inputFileType);
    // Lecture du fichier excel (le nouveau rapport)
    $objPHPExcel = $objReader->load($nouveauRapport);

    It's working perfectly.

    Thanks for the fast reply tho!