Question Detail

I want to export Excel file of Table data when i click on download button. 

I have some user's Data list it should be download on button click in Excel file in Php


Thread Reply

Hemant Sharma

- 6 months ago

To genrate Dynamic Excel File in Php you need to add Liabrary in your project from here and follow Steps
 

In order to get PHPExcel working with CodeIgniter, there are a few steps you must take to ensure compatibility with CodeIgniter's naming standards.

1: Class names must match the file names. PHPExcel has a few files(such as PHPExcel/IOFactory.php) that have names like PHPExcel_IOFactory. Change these names by removing the "PHPExcel_" part. These constructors in these files must be public in order for CI to access them.

  1. To load a library like the IOFactory, simply say: $this->load->library('PHPExcel/iofactory');

A simple use case of PHPExcel would look like:

$this->load->library('phpexcel');
$this->load->library('PHPExcel/iofactory');

$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setTitle("title")
                 ->setDescription("description");
                        
// Assign cell values
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'cell value here');

// Save it as an excel 2003 file
$objWriter = IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save("nameoffile.xls");

Hemant Sharma

- 6 months ago

To genrate Dynamic Excel File in Php you need to add Liabrary in your project from here and follow Steps
 

In order to get PHPExcel working with CodeIgniter, there are a few steps you must take to ensure compatibility with CodeIgniter's naming standards.

1: Class names must match the file names. PHPExcel has a few files(such as PHPExcel/IOFactory.php) that have names like PHPExcel_IOFactory. Change these names by removing the "PHPExcel_" part. These constructors in these files must be public in order for CI to access them.

  1. To load a library like the IOFactory, simply say: $this->load->library('PHPExcel/iofactory');

A simple use case of PHPExcel would look like:

$this->load->library('phpexcel');
$this->load->library('PHPExcel/iofactory');

$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setTitle("title")
                 ->setDescription("description");
                        
// Assign cell values
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->setCellValue('A1', 'cell value here');

// Save it as an excel 2003 file
$objWriter = IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save("nameoffile.xls");