How To Import Excel and CSV File Using CodeIgniter

How To Import Excel and CSV File Using CodeIgniter

Today, In this tutorial, we will be explaining how to import Excel and CSV File Using CodeIgniter. so let’s discuss Import Excel and CSV File.

It’s also very helpful in such as if you want to backup of data and you have data of CSV file then you can import the data into the database.

CSV extension stands for “Comma Separated Values” and contains all data in comma-separated. Normally, we have large data and need to import data into the database that time we use the following file types.

Overview

Step 1: Create a Database in table
Step 2: Connect to Database
Step 3: Download PhpExcel Library
Step 4: Create Controller
Step 5: Create a Model
Step 6: Create View File

Step 1: Create a Database in table
In this step, we have to create a table in the database, so we will create a database using the below code.

Step 2: Connect to Database
Go to the config folder and open database.php file some changes in this file like hostname, database username, database password, and database name.

Step 3: Download PhpExcel Library
First, we need to Download PhpExcel Library. then we will use that third party Library for Codeigniter excel import.
Step 4: Create Controller
In this step, we will create an Import.php file in the “application/controller” directory and paste the below code in this controller.
application/controller/Import.php

Step 5: Create a Model
In this step, we will create an Import_model.php file in the “application/models” directory and paste the below code in this model.
application/models/Import_model.php

 

Step 6: Create View File
So finally, we will create the excel_file_upload.php file in the “application/views/” directory and make a form with google Recaptcha code in HTML.
application/views/excel_file_upload.php

Please follow and like us: