Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The filename feed1.xls is not readable in php

Hi I want to parse an excel file using zend framework. I went to Zend Developer Zone and found a solution to download phpexcelreader. I downloaded the code set a project at localhost and run the code. When I treid to read an .xlsx file it generates an error

The filename feed1.xlsx is not readable

I saved the file in .xls format and run the code parsed the file successfully. Now I want to implement this in my project developed in Zend framework. I created a model, and in my project and require_onceed the excelreader at top of my project like this.

 require_once 'Excelreader/Excel/reader.php';
class ExcelreaderModel extends Zend_Db_Table
{
function readFile()
{
    $data = new Spreadsheet_Excel_Reader();

    // Set output Encoding.
    $data->setOutputEncoding('CP1251');

    //$data->read('Excelreader/Excel/feed1.xls');
    $data->read('feed1.xls');
    echo '<pre>';
    print_r($data);
    echo '</pre>';
}
}

I called this model function in my controller. But it is generating the same error which I found on localhost using .xlsx files. But I am reading .xls file which is parsed by the code running at simple project on localhost.I am also running zend framework at local.

What is wrong in my code? Or is there any way to do the same task.?

like image 963
Awais Qarni Avatar asked Jan 24 '12 07:01

Awais Qarni


1 Answers

I think problem is in encoding type of .xlxs file rather in setting file permission. If you change the permission it will not work for you. Problem is in OLE_IDENTIFIER (��ࡱ�).

So your file data must start with ��ࡱ� data. Even I am looking for proper solution for this. Can any one help ??

like image 175
kumar soneta Avatar answered Sep 19 '22 10:09

kumar soneta