0

I have upgraded the PHP version from 5.1.x to 5.4.14 in which reading of excel files using PHPExcelReader fails with the following warning. In the earlier version, it was working correctly.

The filename images_db/TempCountry.xlsx is not readable

The sample code for demonstration is as follows (It is Temp.php).

<?php 
    require_once 'phpExcelReader/Excel/reader.php';

    if(isset($_POST['btnSubmit']))
    {
        $data = new Spreadsheet_Excel_Reader();     
        $data->setOutputEncoding('CP1251');  // Set output Encoding.
        move_uploaded_file($_FILES["xlfile"]["tmp_name"],"images_db/".$_FILES["xlfile"]["name"]);
        $data->read('images_db/'.$_FILES["xlfile"]["name"]);
    }

?>

<form action="Temp.php" id="dataForm" name="dataForm" method="post" enctype="multipart/form-data">
    <input type="file" id="xlfile" name="xlfile">
    <input type="submit" value="Submit" id="btnSubmit" name="btnSubmit">
</form>

When the given submit button is pressed, the excel file is first uploaded into the images_db/ directory which is successful at which place, the following line,

$data->read('images_db/'.$_FILES["xlfile"]["name"]);

is expected to read this file but it gives the warning as mentioned above.


In the reader.php file, the following line,

$this->_ole =& new OLERead();

has been changed to

$this->_ole = new OLERead();

to avoid the following warning.

Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\wagafashion\phpExcelReader\Excel\reader.php on line 261


Why isn't an excel file (neither xls nor xlsx) read by PHPExcelReader in this new version of PHP? Does it have to do something with the version?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Tiny
  • 27,221
  • 105
  • 339
  • 599
  • 1
    Because Spreadsheet_Excel_Reader has not been updated in many years even simply to reflect the changes in PHP itself, much less to add any new features. It is old and unsupported. Try using a more modern and supported Excel file reader. Besides my own [PHPExcel](https://phpexcel.codeplex.com/) library, you'll find a comprehensive list of readers (and writers) [here](http://stackoverflow.com/questions/3930975/alternative-for-php-excel) – Mark Baker Aug 25 '13 at 12:29
  • 1
    Incidentally, you've tagged this post `phpexcel` but aren't actually using PHPExcel despite the fact that it is an up-to-date Excel reader/writer that won't throw deprecated messages with versions of PHP from 5.2 to 5.5 – Mark Baker Aug 25 '13 at 13:05

0 Answers0