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

phpEXL

时间:2017-07-02 10:13:07      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:eval   样式   idt   output   excel表格   ida   表名   value   生成   

//引用新建对象<br>require "../phpexcel/Classes/PHPExcel.php";
$excel = new PHPExcel();
建表格


//Excel表格式,这里简略写了4列
$letter = array(A,B,C,D,);
 填充值

$excel->getActiveSheet()->setCellValue("A1","差旅费报销单");  //填充A1的值
$excel->getActiveSheet()->mergeCells(A1:D1);          //合并行从A1到D1<br>$excel->getActiveSheet()->mergeCells(‘C7:c10‘);       //合并列从C7到C10<br>
$excel->getActiveSheet()->setCellValue("A2","姓名");
$excel->getActiveSheet()->setCellValue("B2","{$name}");
$excel->getActiveSheet()->setCellValue("C2","部门");
$excel->getActiveSheet()->setCellValue("D2","{$bm}");
 表格样式设置


$excel->getActiveSheet()->getColumnDimension(A)->setWidth(13);//设置列的宽度
$excel->getActiveSheet()->getColumnDimension(B)->setWidth(30);
$excel->getActiveSheet()->getColumnDimension(C)->setWidth(13);
$excel->getActiveSheet()->getColumnDimension(D)->setWidth(30);
$excel->getActiveSheet()->getRowDimension(5)->setRowHeight(100);
 //设置行的高度数字代表第几行
$excel->getActiveSheet()->getRowDimension(2)->setRowHeight(25);
$excel->getActiveSheet()->getRowDimension(3)->setRowHeight(25);
$excel->getActiveSheet()->getRowDimension(4)->setRowHeight(25);
$excel->getActiveSheet()->getRowDimension(6)->setRowHeight(25);<br>$excel->getActiveSheet()->getStyle(A1)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);//横向居中<br>$excel->getActiveSheet()->getStyle(‘A1‘)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);//纵向居中
生成表格


$write = new PHPExcel_Writer_Excel5($excel);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");;
header("Content-Disposition:attachment;filename={$ids}出差报销表.xls");//要生成的表名
header("Content-Transfer-Encoding:binary");
$write->save(php://output);

 

phpEXL

标签:eval   样式   idt   output   excel表格   ida   表名   value   生成   

原文地址:http://www.cnblogs.com/gyzown/p/7105081.html

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