成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

Codeigniter生成Excel文檔的簡單方法

2013-05-09 23:36:03來源:西部e網作者:icech

之前看了使用PHPExcel中導出數據到Excel文件的方法,但是似乎比較復雜。icech找到了一個針對Codeigniter的類:CI-Excel-Generation-Library,使用方法十分簡單。

之前看了使用PHPExcel中導出數據到Excel文件的方法,但是似乎比較復雜。icech找到了一個針對Codeigniter的類:CI-Excel-Generation-Library,使用方法十分簡單。

1、下載CI-Excel-Generation-Library

地址:https://github.com/JOakley77/CI-Excel-Generation-Library

2、將Excel.php放到libraries里面

3、使用方法:

從數據庫生成excel

<?php
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);
}
?>

從數組生成excel

<?php
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);
}
?>

怎么樣,很簡單吧?

關鍵詞:CodeigniterExcel

贊助商鏈接:

主站蜘蛛池模板: 砚山县| 西和县| 含山县| 张掖市| 伊宁市| 忻州市| 崇文区| 安阳市| 光山县| 大丰市| 林芝县| 株洲市| 福鼎市| 博兴县| 行唐县| 灵武市| 衢州市| 天等县| 宜昌市| 如东县| 汉沽区| 临武县| 府谷县| 四川省| 河间市| 开封市| 新乡市| 思茅市| 涪陵区| 阳城县| 当涂县| 大埔县| 天水市| 彭山县| 新民市| 黄梅县| 仪征市| 巴楚县| 离岛区| 科技| 丰都县|