I looked at the method of exporting data to Excel files using PHPExcel before, but it seemed more complicated. icech found a class for Codeigniter: CI-Excel-Generation-Library, which is very simple to use.
1. Download CI-Excel-Generation-Library
Address: https://github.com/JOakley77/CI-Excel-Generation-Library
2. Put Excel.php into libraries
3. How to use:
Generate excel from database
Copy code The 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);
}
?>
Generate excel from array
Copy code The code is as follows:
public function export() {
$titles = array('field1', 'field2', 'field3');
$array = array();
for ($i = 0; $i <= 100; $i++) {
$array[] = array($i, $i+1, $i+2);
}
$this->excel->make_from_array($titles, $array);
}
?>
How about it, it’s very simple, right?
http://www.bkjia.com/PHPjc/788631.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/788631.htmlTechArticleI have seen the method of exporting data to Excel files using PHPExcel before, but it seems more complicated. icech found a class for Codeigniter: CI-Excel-Generation-Library, using the method...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn