Recently I use Spreadsheet_Excel_Reader for reading a .xls file in codeigniter. I have done the follo开发者_开发百科wing step :
- paste the Spreadsheet_Excel_Reader in system/application/libraries.
- change error_reporting in your index.php to error_reporting(E_ALL ^ E_NOTICE);
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.
精彩评论