php - Read .xlsx and .xls data in codeigniter -


i want read data of .xlsx or .xls file in codeigniter. have read other questions related nothing works. have used phpexcel, reader no luck. in project give option upload excel file want read data , insert in database.

now using phpexcel library have wrote:

    $this->load->library('excel');     $reader= phpexcel_iofactory::createreader('excel2007');     $reader->setreaddataonly(true);     $path=(fcpath.'uploads/productfile/'.$_files['upload_file']['name']);     $excel=$reader->load($path);     $sheet=$excel->setactivesheetindex(0);     for($i=0;$i<=1000;$i++)     {       $col1= $sheet->getcellbycolumnandrow(0,$i)->getvalue();       $col2= $sheet->getcellbycolumnandrow(1,$i)->getvalue();       $col3= $sheet->getcellbycolumnandrow(2,$i)->getvalue();       var_dump($col1);     } 

but display :

uncaught exception 'phpexcel_exception' message 'you tried set sheet active out of bounds index: 0. actual number of sheets 0 please give me example code.

the error enter image description here please give me example code:

try :

 $sheet = $excel->getactivesheet()->toarray(null,true,true,true); 

this return array of current active sheet.hope helps.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -