开发者

File is not readable for excel reader in codeigniter

开发者 https://www.devze.com 2023-02-13 06:36 出处:网络
Recently I use Spreadsheet_Excel_Reader for reading a .xls file in codeigniter. I have done the follo开发者_开发百科wing step :

Recently I use Spreadsheet_Excel_Reader for reading a .xls file in codeigniter. I have done the follo开发者_开发百科wing step :

  1. paste the Spreadsheet_Excel_Reader in system/application/libraries.
  2. change error_reporting in your index.php to error_reporting(E_ALL ^ E_NOTICE);
  3. Then write the following code in my controller :

    $pathToFile = base_url().'uploads/loop.xls';
    $params = array('file' => $pathToFile, 'store_extended_info' => true);
    
    $this->load->library('Spreadsheet_Excel_Reader', $params);
    $data['xlsFile'] = $this->spreadsheet_excel_reader->dump(false, false, 0, 'excel');
    $this->load->view('test.php', $data);
    

But the problem was this show the following error :

   The filename http://www.example.com/uploads/loop.xls is not readable.

Here the file location is correct. The file is also in .xls format. How can I solve this error?


Check that allow_url_fopen is set to on in php.ini.

May be using the real path instead of url can be an alternative solution.


Maybe there's a problem with the file permissions, it should be read/write for webserver


Please use FCPATH.'uploads/loop.xls'; ( whatever Your file path )

its working for me, you can try this.


Please try change:

$pathToFile = base_url().'uploads/loop.xls';

to:

$pathToFile = './uploads/loop.xls';

Thanks.


Your excel file won't be readable due to following causes---

1.) You don't have original Microsoft Office 2.) Your extension may be incorrect.

Solution->

Uninstall your pirated Office and install kingsoft or libre office than your excel will definately work.

0

精彩评论

暂无评论...
验证码 换一张
取 消