{"id":1630,"date":"2017-06-13T18:28:38","date_gmt":"2017-06-13T12:58:38","guid":{"rendered":"https:\/\/blog.pheonixsolutions.com\/?p=1630"},"modified":"2017-06-13T18:28:38","modified_gmt":"2017-06-13T12:58:38","slug":"export-data-database-excel-sheet-xls-using-codeigniter","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/","title":{"rendered":"Export data from Database to Excel Sheet(.xls) using Codeigniter"},"content":{"rendered":"<p><strong>Date Posted:13-06-2017<\/strong><br \/>\nIn this post\u00a0 we will explain export data from database using PHPExcel libary<br \/>\nI assume that you are configure or setup the codeigniter<\/p>\n<p>Step 1:Create the mysql table currency,use following code<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\">-- phpMyAdmin SQL Dump\r\n-- version 3.5.2.2\r\n-- http:\/\/www.phpmyadmin.net\r\n--\r\n-- Host: 127.0.0.1\r\n-- Generation Time: Jun 13, 2017 at 02:38 PM\r\n-- Server version: 5.5.27\r\n-- PHP Version: 5.4.7\r\n\r\nSET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";\r\nSET time_zone = \"+00:00\";\r\n\r\n\r\n\/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT *\/;\r\n\/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS *\/;\r\n\/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION *\/;\r\n\/*!40101 SET NAMES utf8 *\/;\r\n\r\n--\r\n-- Database: `chatigniter`\r\n--\r\n\r\n-- --------------------------------------------------------\r\n\r\n--\r\n-- Table structure for table `users`\r\n--\r\n\r\nCREATE TABLE IF NOT EXISTS `users` (\r\n  `id` int(11) NOT NULL AUTO_INCREMENT,\r\n  `firstname` varchar(255) NOT NULL,\r\n  `lastname` varchar(255) NOT NULL,\r\n  `email` varchar(255) NOT NULL,\r\n  `username` varchar(255) NOT NULL,\r\n  `password` varchar(255) NOT NULL,\r\n  `avatar` varchar(255) NOT NULL,\r\n  `online` enum('1','0') NOT NULL DEFAULT '1',\r\n  `created_at` datetime NOT NULL,\r\n  `updated_at` datetime NOT NULL,\r\n  PRIMARY KEY (`id`)\r\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;\r\n\r\n--\r\n-- Dumping data for table `users`\r\n--\r\n\r\nINSERT INTO `users` (`id`, `firstname`, `lastname`, `email`, `username`, `password`, `avatar`, `online`, `created_at`, `updated_at`) VALUES\r\n(1, 'test', 'ytest', 'k@gmail.com', 'karthik', '', '', '1', '0000-00-00 00:00:00', '0000-00-00 00:00:00')\r\n\/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT *\/;\r\n\/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS *\/;\r\n\/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION *\/;\r\n<\/pre>\n<p>step2:Download PHPExcel libarry from it\u2019s github repository or you can download it from PHPExcel official website.<br \/>\nDwonload PHPExcel library<br \/>\nDwonload PHPExcel library from GIThub repository from <a href=\"https:\/\/phpexcel.codeplex.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/phpexcel.codeplex.com\/<\/a><\/p>\n<p>Step3:<\/p>\n<p>After download you find three differnt folder Classes,Documentation,Examples in PHPExcel.navigate to application\/thirdparty extract PHPExcel-&gt;Classes-&gt;PHPExcel.php and PHPExcel directory directory here.<\/p>\n<p>Step4:<br \/>\nNavigate to application\/libraries and create new file name as ExcelExport_lib.php,place following code here<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\">&lt;?php\r\n\r\nif (!defined('BASEPATH'))\r\n    exit('No direct script access allowed');\r\n\r\nclass Excel {\r\n\r\n    private $excel;\r\n\r\n    public function __construct() {\r\n        require_once APPPATH . 'third_party\/PHPExcel.php';\r\n        $this-&gt;excel = new PHPExcel();\r\n    }\r\n\r\n    public function load($path) {\r\n        $objReader = PHPExcel_IOFactory::createReader('Excel5');\r\n        $this-&gt;excel = $objReader-&gt;load($path);\r\n    }\r\n\r\n    public function save($path) {\r\n        $objWriter = PHPExcel_IOFactory::createWriter($this-&gt;excel, 'Excel5');\r\n        $objWriter-&gt;save($path);\r\n    }\r\n\r\n    public function stream($filename, $data = null) {\r\n\r\n        if ($data != null) {\r\n            $col = 'A';\r\n            foreach ($data[0] as $key =&gt; $val) {\r\n                $objRichText = new PHPExcel_RichText();\r\n                $objPayable = $objRichText-&gt;createTextRun(str_replace(\"_\", \" \", $key));\r\n                $this-&gt;excel-&gt;getActiveSheet()-&gt;getCell($col . '1')-&gt;setValue($objRichText);\r\n                $col++;\r\n            }\r\n            $rowNumber = 2;\r\n            foreach ($data as $row) {\r\n                $col = 'A';\r\n                foreach ($row as $cell) {\r\n                    $this-&gt;excel-&gt;getActiveSheet()-&gt;setCellValue($col . $rowNumber, $cell);\r\n                    $col++;\r\n                }\r\n                $rowNumber++;\r\n            }\r\n        }\r\n        header('Content-type: application\/ms-excel');\r\n        header(\"Content-Disposition: attachment; filename=\\\"\" . $filename . \"\\\"\");\r\n        header(\"Cache-control: private\");\r\n        $objWriter = PHPExcel_IOFactory::createWriter($this-&gt;excel, 'Excel5');\r\n       \/\/ $objWriter-&gt;save(\"export\/$filename\");\r\n        $objWriter-&gt;save('php:\/\/output'); \/\/change by Pavan\r\n        header(\"location: \" . base_url() . \"export\/$filename\");\r\n       \/\/ unlink(base_url() . \"export\/$filename\");\r\n    }\r\n\r\n    public function __call($name, $arguments) {\r\n        if (method_exists($this-&gt;excel, $name)) {\r\n            return call_user_func_array(array($this-&gt;excel, $name), $arguments);\r\n        }\r\n        return null;\r\n    }\r\n}<\/pre>\n<p>Step5:<br \/>\nNavigate to application\/controllers and create new file name as ExportExcel.php,place following code here<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;?php\r\nif ( ! defined('BASEPATH')) exit('No direct script access allowed'); \r\n\/**\r\n * summary\r\n *\/\r\nclass ExportExcel extends CI_Controller\r\n{\r\n    public function index()\r\n    {\r\n    \t$this-&gt;load-&gt;view('excelexport');\t\r\n    }\r\n    public function Export()\r\n    {\r\n        $this-&gt;load-&gt;library('excelexport_lib');\r\n \t\t\t\r\n     \t\r\n        $assign_res_data =$this-&gt;db-&gt;get('users')-&gt;result();\r\n\r\n        \/\/ print_r($assign_res_data);die;\r\n        $title = date('Y-m-d').\"_\".\"AssignmentReport\" ;\r\n\r\n        \/*export data in exlsheet start*\/\r\n            $this-&gt;excelexport_lib-&gt;setActiveSheetIndex(0);\r\n            \/\/name the worksheet\r\n            $this-&gt;excelexport_lib-&gt;getActiveSheet()-&gt;setTitle($title);\r\n          \/\/make the font become bold\r\n            $this-&gt;excelexport_lib-&gt;getActiveSheet()-&gt;getStyle('A1')-&gt;getFont()-&gt;setBold(true);\r\n            $this-&gt;excelexport_lib-&gt;getActiveSheet()-&gt;getStyle('A1')-&gt;getFont()-&gt;setSize(20);\r\n            $this-&gt;excelexport_lib-&gt;getActiveSheet()-&gt;getStyle('A1')-&gt;getFill()-&gt;getStartColor()-&gt;setARGB('#5545');\r\n\r\n\r\n\r\n             for($col = ord('A'); $col &lt;= ord('H'); $col++)\r\n             {\t\r\n                  \/\/set column dimension\r\n                  $this-&gt;excelexport_lib-&gt;getActiveSheet()-&gt;getColumnDimension(chr($col))-&gt;setAutoSize(true);\r\n                   \/\/change the font size\r\n                  $this-&gt;excelexport_lib-&gt;getActiveSheet()-&gt;getStyle(chr($col))-&gt;getFont()-&gt;setSize(12);\r\n                   \r\n                  $this-&gt;excelexport_lib-&gt;getActiveSheet()-&gt;getStyle(chr($col))-&gt;getAlignment()-&gt;setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);\r\n              }  \r\n        $this-&gt;excelexport_lib-&gt;stream($title.'.xls', $assign_res_data);\r\n    }\r\n}\r\n\r\n?&gt;<\/pre>\n<p>Step6:<br \/>\nNavigate to application\/view and create new file name as excelexport.php,place following code here<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;?php\r\ndefined('BASEPATH') OR exit('No direct script access allowed');\r\n?&gt;&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=\"utf-8\"&gt;\r\n    &lt;title&gt;Welcome to Export Database&lt;\/title&gt;\r\n\r\n    &lt;style type=\"text\/css\"&gt;\r\n\r\n    ::selection { background-color: #E13300; color: white; }\r\n    ::-moz-selection { background-color: #E13300; color: white; }\r\n\r\n    body {\r\n        background-color: #fff;\r\n        margin: 40px;\r\n        font: 13px\/20px normal Helvetica, Arial, sans-serif;\r\n        color: #4F5155;\r\n    }\r\n\r\n    a {\r\n        color: #003399;\r\n        background-color: transparent;\r\n        font-weight: normal;\r\n    }\r\n\r\n    h1 {\r\n        color: #444;\r\n        background-color: transparent;\r\n        border-bottom: 1px solid #D0D0D0;\r\n        font-size: 19px;\r\n        font-weight: normal;\r\n        margin: 0 0 14px 0;\r\n        padding: 14px 15px 10px 15px;\r\n    }\r\n\r\n    code {\r\n        font-family: Consolas, Monaco, Courier New, Courier, monospace;\r\n        font-size: 12px;\r\n        background-color: #f9f9f9;\r\n        border: 1px solid #D0D0D0;\r\n        color: #002166;\r\n        display: block;\r\n        margin: 14px 0 14px 0;\r\n        padding: 12px 10px 12px 10px;\r\n    }\r\n\r\n    #body {\r\n        margin: 0 15px 0 15px;\r\n    }\r\n\r\n    p.footer {\r\n        text-align: right;\r\n        font-size: 11px;\r\n        border-top: 1px solid #D0D0D0;\r\n        line-height: 32px;\r\n        padding: 0 10px 0 10px;\r\n        margin: 20px 0 0 0;\r\n    }\r\n\r\n    #container {\r\n        margin: 10px;\r\n        border: 1px solid #D0D0D0;\r\n        box-shadow: 0 0 8px #D0D0D0;\r\n    }\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n<div id=\"container\">\r\n    <h1>Export Excel!<\/h1>\r\n\r\n    <div id=\"body\">\r\n    <form>\" enctype=\"multipart\/form-data\" method=\"POST\" role=\"form\"&gt;\r\n    \r\n        \r\n    \r\n        <button type=\"submit\" class=\"btn btn-primary\">Click to Export<\/button>\r\n    <\/form>\r\n\r\n<\/div>\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Date Posted:13-06-2017 In this post\u00a0 we will explain export data from database using PHPExcel libary I assume that you are configure or setup the codeigniter Step 1:Create the mysql table currency,use following code &#8212; phpMyAdmin SQL Dump &#8212; version 3.5.2.2 &#8212; http:\/\/www.phpmyadmin.net &#8212; &#8212; Host: 127.0.0.1 &#8212; Generation Time: Jun&hellip; <a href=\"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/\" class=\"more-link read-more\" rel=\"bookmark\">Continue Reading <span class=\"screen-reader-text\">Export data from Database to Excel Sheet(.xls) using Codeigniter<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[340,221],"tags":[341,273],"class_list":{"0":"post-1630","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-codeigniter","7":"category-php","8":"tag-codeigniter","9":"tag-php","10":"h-entry","12":"h-as-article"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pheonix Solutions - We Empower Your Business Growth<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pheonix Solutions - We Empower Your Business Growth\" \/>\n<meta property=\"og:description\" content=\"Date Posted:13-06-2017 In this post\u00a0 we will explain export data from database using PHPExcel libary I assume that you are configure or setup the codeigniter Step 1:Create the mysql table currency,use following code -- phpMyAdmin SQL Dump -- version 3.5.2.2 -- http:\/\/www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Jun&hellip; Continue Reading Export data from Database to Excel Sheet(.xls) using Codeigniter\" \/>\n<meta property=\"og:url\" content=\"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/\" \/>\n<meta property=\"og:site_name\" content=\"PHEONIXSOLUTIONS\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-13T12:58:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/09\/PX2.png\" \/>\n\t<meta property=\"og:image:width\" content=\"3837\" \/>\n\t<meta property=\"og:image:height\" content=\"2540\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pheonixsolution\" \/>\n<meta name=\"twitter:site\" content=\"@pheonixsolution\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/export-data-database-excel-sheet-xls-using-codeigniter\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/export-data-database-excel-sheet-xls-using-codeigniter\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/0ffa33d73c869faec2d50e79c24e3503\"},\"headline\":\"Export data from Database to Excel Sheet(.xls) using Codeigniter\",\"datePublished\":\"2017-06-13T12:58:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/export-data-database-excel-sheet-xls-using-codeigniter\\\/\"},\"wordCount\":160,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\"},\"keywords\":[\"codeigniter\",\"php\"],\"articleSection\":[\"Codeigniter\",\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/export-data-database-excel-sheet-xls-using-codeigniter\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/export-data-database-excel-sheet-xls-using-codeigniter\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/export-data-database-excel-sheet-xls-using-codeigniter\\\/\",\"name\":\"Pheonix Solutions - We Empower Your Business Growth\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#website\"},\"datePublished\":\"2017-06-13T12:58:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/export-data-database-excel-sheet-xls-using-codeigniter\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/export-data-database-excel-sheet-xls-using-codeigniter\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/export-data-database-excel-sheet-xls-using-codeigniter\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Export data from Database to Excel Sheet(.xls) using Codeigniter\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\",\"name\":\"Pheonix Solutions\",\"description\":\"We Empower Your Business Growth\",\"publisher\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#organization\",\"name\":\"PheonixSolutions\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/12\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/12\\\/logo.png\",\"width\":454,\"height\":300,\"caption\":\"PheonixSolutions\"},\"image\":{\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/PheonixSolutions-209942982759387\\\/\",\"https:\\\/\\\/x.com\\\/pheonixsolution\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/0ffa33d73c869faec2d50e79c24e3503\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"http:\\\/\\\/blog.pheonixsolutions.com\"],\"url\":\"https:\\\/\\\/pheonixsolutions.com\\\/blog\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pheonix Solutions - We Empower Your Business Growth","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/","og_locale":"en_US","og_type":"article","og_title":"Pheonix Solutions - We Empower Your Business Growth","og_description":"Date Posted:13-06-2017 In this post\u00a0 we will explain export data from database using PHPExcel libary I assume that you are configure or setup the codeigniter Step 1:Create the mysql table currency,use following code -- phpMyAdmin SQL Dump -- version 3.5.2.2 -- http:\/\/www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: Jun&hellip; Continue Reading Export data from Database to Excel Sheet(.xls) using Codeigniter","og_url":"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/","og_site_name":"PHEONIXSOLUTIONS","article_publisher":"https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/","article_published_time":"2017-06-13T12:58:38+00:00","og_image":[{"width":3837,"height":2540,"url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/09\/PX2.png","type":"image\/png"}],"author":"admin","twitter_card":"summary_large_image","twitter_creator":"@pheonixsolution","twitter_site":"@pheonixsolution","twitter_misc":{"Written by":"admin","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/#article","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/"},"author":{"name":"admin","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/person\/0ffa33d73c869faec2d50e79c24e3503"},"headline":"Export data from Database to Excel Sheet(.xls) using Codeigniter","datePublished":"2017-06-13T12:58:38+00:00","mainEntityOfPage":{"@id":"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/"},"wordCount":160,"commentCount":0,"publisher":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#organization"},"keywords":["codeigniter","php"],"articleSection":["Codeigniter","PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/","url":"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/","name":"Pheonix Solutions - We Empower Your Business Growth","isPartOf":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#website"},"datePublished":"2017-06-13T12:58:38+00:00","breadcrumb":{"@id":"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/pheonixsolutions.com\/blog\/export-data-database-excel-sheet-xls-using-codeigniter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/pheonixsolutions.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Export data from Database to Excel Sheet(.xls) using Codeigniter"}]},{"@type":"WebSite","@id":"https:\/\/pheonixsolutions.com\/blog\/#website","url":"https:\/\/pheonixsolutions.com\/blog\/","name":"Pheonix Solutions","description":"We Empower Your Business Growth","publisher":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/pheonixsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/pheonixsolutions.com\/blog\/#organization","name":"PheonixSolutions","url":"https:\/\/pheonixsolutions.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/12\/logo.png","contentUrl":"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/12\/logo.png","width":454,"height":300,"caption":"PheonixSolutions"},"image":{"@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/PheonixSolutions-209942982759387\/","https:\/\/x.com\/pheonixsolution"]},{"@type":"Person","@id":"https:\/\/pheonixsolutions.com\/blog\/#\/schema\/person\/0ffa33d73c869faec2d50e79c24e3503","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/09bacc0294abee1322a23ab4bc6a0330dd4cb4df707dc9d0b0efeba6c109608b?s=96&r=g","caption":"admin"},"sameAs":["http:\/\/blog.pheonixsolutions.com"],"url":"https:\/\/pheonixsolutions.com\/blog\/author\/admin\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7F4uM-qi","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1630"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1630\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}