I have downloaded php excel exporter library from http://phpexportxlsclass.googlecode.com/files/export-xls.class-v1.01.zip
It works fine if I run demo.php file independantly from the zip.
I have included export-xls.class.php file in libraries folder and called that library from controller
here is the code snippet
function export_to_excel() {
require(APPPATH.'libraries/exportxls.php');
$config['filename'] = 'test1.xls'; // The file name you want any resulting file to be called.
$xls = new ExportXLS($config);
$xls->addHeader("Test Spreadsheet");
$xls->addHeader(null);
$header = array("Name", "Age", "Height");
$xls->addHeader($header);
$row = array();
$row[] = array('Jack', '24', '6ft');
$row[] = array('Jim', '22', '5ft');
$row[] = array('Jess', '54', '4ft');
$row[] = array('Luke', '6', '2ft');
$xls->addRow($row);
$xls->sendFile();
}
but when I run my code using url http://www.domain.com/controller/export_to_excel
then it will give me following excel file as an output.
For windows support: add these line in private function textFormat($row, $col, $data)
iconv("UTF-8", "CP1252", $data);
see this for more discussion on this issue.