Create Excel file using PHP Codeigniter Create Excel file using PHP Codeigniter codeigniter codeigniter

Create Excel file using PHP Codeigniter


This has been answered at the following link:

How to use the CSV MIME-type?

Although it outputs a CSV MIME type, Excel is usually the default application for CSV.

Oops. Forgot the CodeIgniter part :)

Based on the above link, you can create a controller similar to the following, assuming CI 2.x

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');class Csv extends CI_Controller {    public function index() {        header('Content-type: text/csv');        header('Content-disposition: attachment;filename=fromci.csv');        echo "order,id,Name,Address,Quantity,Price,Total".PHP_EOL;        echo "1,1,XXXX,YYYYYYY,10,700,7000".PHP_EOL;    }}


This excel.php file could prove useful to you as an alternative to php-excel. I've never personally used it, but the description sounds like it could work for you.

http://www.phpclasses.org/package/1919-PHP-Stream-wrapper-to-read-and-write-MS-Excel-files.html