CodeIgniter Forums

Full Version: write and read excel files with codeigniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Sudz[/eluser]
Can anybody help me,

Is there any library or helper to write and read excel file in codeigniter?

El Forum

[eluser]louisl[/eluser]
You can use html tables as Excel documents.

El Forum

[eluser]michalsn[/eluser]
[quote author="Sudhakar Prajapati" date="1303994788"]Is there any library or helper to write and read excel file in codeigniter?[/quote] No, but you can use PHPExcel http://phpexcel.codeplex.com/
CI wiki: http://codeigniter.com/wiki/PHPExcel/ and some tutorial: http://virusandlinux.baskoroadi.web.id/i...deigniter/

El Forum

[eluser]Seb[/eluser]
The user guide given on the previous post is a little bit deprecated for the current CI.

You can follow the directives at http://codeigniter.com/wiki/PHPExcel/ and then for example to generate XLSX on the fly :

Code:
$this->load->library('PHPExcel');
$this->load->library('PHPExcel/IOFactory');

$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Hello');
$objPHPExcel->getActiveSheet()->SetCellValue('B2', 'world!');

$objWriter = IOFactory::createWriter($objPHPExcel, 'Excel2007');

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="Filename.xlsx"');
header('Cache-Control: max-age=0');
$objWriter->save('php://output');