Export MySQL To Excel Using PHP

Inserting data to your database and getting all the data when required is a much needed operation in websites maintenance or development. So making all these operations easy is really needy.

I am presenting you a PHP script to export mysql to excel sheet and download. Script is orginally written by¬†Oliver Schwarz <[email protected]>

Following are the script to call the class file and produce the output. Just download the php file and class file and follow the following steps,

1 : Create Download Link

<a href=”export.php”>Export To Excel</a>

2 : Include the .class file to “php-excel.php”

// load library
require ‘php-excel.class.php’;

3 : Include db file for database connection

// load your db file for databse connection
require ‘php-db-connect.php’;

4 : Set your column names for excel file

5 : Create loop to fetch data and write to excel file

6 : Create Excel File & Export MySQL to Excel

Its so easy and handy to use. Download Export-To-Excel.zip

dipak Written by: