织梦cms自定义表单数据导出excel

请问织梦cms自定义表单数据导出excel该怎么做

提问者phpcn_u2562提问时间:2017-08-04 08:40我来回答
1回答
PHP中文网
回复PHP中文网赞同02个月前
<?php
$dir=dirname(__FILE__);
require $dir."/PHPExcel.php";
$objPHPExcel=new PHPExcel();
$objSheet=$objPHPExcel->getActiveSheet();
$objSheet->setTitle("demo");
//$objSheet->setCellValue("A1","可可")->setCellValue("b1","蛋蛋");
$array=array(
array("姓名","年龄"),
array("大可","58")
);
$objSheet->fromArray($array);
$objWriter=PHPExcel_IOFactory::createWriter($objPHPExcel,"Excel5");
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
 
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="ch3.xls"');
header('Cache-Control: max-age=0');
$objWriter->save("php://output");