I looked at the method of using Phpexcel to export data to an Excel file, but it seems more complicated. Icech found a class for CodeIgniter: Ci-excel-generation-library, the use of the method is very simple.
1. Download ci-excel-generation-library
Address: Https://github.com/JOakley77/CI-Excel-Generation-Library
2, put the excel.php into the libraries inside
3. How to use:
To generate Excel from a database
Copy CodeThe code is as follows: Public Function export () {
$this->load->library (' table ');
$this->load->library (' Excel ');
$sql = $this->db->get (' dbtable ');
$query->result ();
$this->excel->filename = ' abc123 ';
$this->excel->make_from_db ($sql);
}
?>
Generating Excel from an array
Copy CodeThe code is as follows: Public Function export () {
$titles = Array (' field1 ', ' field2 ', ' field3 ');
$array = Array ();
for ($i = 0; $i <=; $i + +) {
$array [] = Array ($i, $i +1, $i +2);
}
$this->excel->make_from_array ($titles, $array);
}
?>
How's that, easy?
http://www.bkjia.com/PHPjc/788631.html www.bkjia.com true http://www.bkjia.com/PHPjc/788631.html techarticle I looked at the method of using Phpexcel to export data to an Excel file, but it seems more complicated. Icech found a class for CodeIgniter: Ci-excel-generation-library, how to use ...