PHPExcel中⽂使⽤⼿册详解安装
php手册官方中文版composer require "phpoffice/phpexcel"
使⽤:
已⾃动加载
实例化
⼀、
$objPHPExcel = new \PHPExcel();
/* 以下是⼀些设置,什么作者标题啊之类的 */
$objPHPExcel->getProperties()->setCreator("实习⽹");
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', ('序号'))
-
>setCellValue('B1', ('订单号'))
->setCellValue('C1', ('职位名称'))
->setCellValue('D1', ('供职公司'))
->setCellValue('E1', ('申请时间'))
->setCellValue('F1', ('⽤户名'))
->setCellValue('G1', ('订单状态'))
->setCellValue('H1', ('总价'));
foreach ($orderList as $k => $v) {
$num = $k + 2;
$objPHPExcel->setActiveSheetIndex(0)
//Excel的第A列,uid是你查出数组的键值,下⾯以此类推
-
>setCellValue('A' . $num, $v['id'])
->setCellValue('B' . $num, ($v['order_number']))
->setCellValue('C' . $num, ($v['job_name']))
->setCellValue('D' . $num, ($v['company_name']))
->setCellValue('E' . $num, $v['addtime'])
->setCellValue('F' . $num, ($v['username']))
->setCellValue('G' . $num, ($v['status']))
->setCellValue('H' . $num, $v['service_money']);
}
unset($num);
static $shxi = '订单';
$objPHPExcel->getActiveSheet()->setTitle('Member');
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$objPHPExcel->setActiveSheetIndex(0);
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$shxi. date('Ymd',time()) . '.xls"');
header('Cache-Control: max-age=0');
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论