In this video , you will be able to upload excel using phpspreadsheet in CodeIgniter.
Steps:
Create a form and input type file
In your controller, get file and check for extension
pathinfo - get the file extension (PATHINFO_EXTENSION)
For csv - $reader= new \PhpOffice\PhpSpreadsheet\Reader\Csv();
For xls - $reader= new \PhpOffice\PhpSpreadsheet\Reader\Xls();
For xlsx - $reader= new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
For loading the file use reader load function
getActiveSheet - for getting the active worksheet of excel
toArray - fetch the sheet data into array
create an array for inserting into database
insert_batch - for inserting batch data into database
Install php spreadsheet in codeigniter, if you have not watched it please check it out:
• Installation of PhpSpr...
Create excel
• Create Excel Using PHP...
Documentation:
phpspreadsheet.readthedocs.io...
Starting hello world:
phpspreadsheet.readthedocs.io...
Code Link:
github.com/sushma-singh-yadav...
Upload Excel in MySQL using Phpspreadsheet in CodeIgniter
#codeigniter #knowledgethrusters
14 май 2021