首页 > 代码库 > phpEXL
phpEXL
//引用新建对象<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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。