Import Excel file into MySQL using Codeigniter

In this post, we are going to explain “How to import Excel file into mysql using CodeIgnitor”  using PHPExcel library.For this things we will use third party PHPExcel library in Codeigniter for Import Excel sheet data into MySQL Database that means first we will read excel sheet data and then after we will store into PHP array and lastly we will perform batch operation that means in a single query execution we will insert multiple data. In Codeigniter framework there is one insert_batch() query builder method by using this method we can insert multiple data in single query execution.This all process will cover step by step in this post.

Step 1:- First, we need to download  PHPExcel Library. Then extract PHPExcel Library inside “application/third_party” folder.


Step 2:- Create database and table or  copy below code and run in mysql for create table

Step 3:- Now create controller file Import.php and copy below code and paste in import.php file.

Step 4:- Now create import_model.php inside model folder and copy below code and paste in import_model.php

Step 5:- Now create view file inside view folder and copy below code and paste in upload.php file

We hope that this article is very helpful for creating excel import functionality in web application. You may also want to learn export functionality then click export csv file in php .

Thanks!!!

Add a Comment

Your email address will not be published. Required fields are marked *