码迷,mamicode.com
首页 > Web开发 > 详细

PHPExcel_CI操作实例

时间:2016-05-12 00:07:47      阅读:416      评论:0      收藏:0      [点我收藏+]

标签:ci、phpexcel


header(‘Content-Type: application/vnd.ms-excel‘);

header(‘Content-Disposition: attachment;filename="123.csv"‘);

header(‘Cache-Control: max-age=0‘);

$this->load->library(‘PHPExcel‘);

//设置文件属性

$this->phpexcel->getProperties()->setCreator(‘林泉‘);

$this->phpexcel->getProperties()->setLastModifiedBy(‘林泉‘);

$this->phpexcel->getProperties()->setTitle(‘PHPExcel测试‘);

$this->phpexcel->getProperties()->setSubject(‘PHPExcel测试‘);

$this->phpexcel->getProperties()->setDescription(‘这个是测试‘);

$this->phpexcel->getProperties()->setKeywords(‘PHP Excel 测试‘);

$this->phpexcel->getProperties()->setCategory(‘我我我‘);

//添加数据

$this->phpexcel->setActiveSheetIndex(0);

for($i=1;$i<21;$i++){

$this->phpexcel->getActiveSheet()->setCellValue(‘A‘.$i,$i);

$this->phpexcel->getActiveSheet()->setCellValue(‘B‘.$i,10*$i);

$this->phpexcel->getActiveSheet()->setCellValue(‘C‘.$i,100*$i);

$this->phpexcel->getActiveSheet()->setCellValue(‘D‘.$i,time());

}

//写文件

$obj_writer = new PHPExcel_Writer_CSV($this->phpexcel);

$obj_writer->setDelimiter(‘;‘);

$obj_writer->setEnclosure(‘‘);

$obj_writer->setLineEnding(‘\r\n‘);

$obj_writer->setSheetIndex(0);

$obj_writer->save(‘php://output‘);



PHPExcel_CI操作实例

标签:ci、phpexcel

原文地址:http://1150895809.blog.51cto.com/9164250/1772353

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!