csv xlsx导出数据
$excel = new PHPExcel();
$sheet = $excel->getActiveSheet();
$sheet->setCellValue('A1', '支付时间');
$sheet->setCellValue('B1', '创建时间');
$sheet->setCellValue('C1', '商户订单号');
$sheet->setCellValue('D1', '产品编号');
$i = 2;
foreach ($orderData as $val) {
$sheet->setCellValue('A' . $i, $val['payTime']);
$sheet->setCellValue('B' . $i, $val['creatTime']);
$sheet->setCellValue('C' . $i, $val['orderNum']);
$sheet->setCellValue('D' . $i, $val['productNum']);
$i++;
}
$timestamp = time();
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="***文件夹名称"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
$objWriter->save('php://output');
exit;
$filename = date('Ymd') . '.csv';
header("Content-type:text/csv");
header("Content-Disposition:attachment;filename=" . $filename);
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Expires:0');
header('Pragma:public');
$ss = "支付时间,创建时间,商户订单号,产品编号,\r\n";
foreach ($orderData as $k => $v) {
$ss .= $v['payTime'] . "," . $v['creatTime'] . "," . $v['orderNum'] . "," . $v['productNum'] . "," . "\r\n";
}
exit(mb_convert_encoding($ss,'gb2312','utf-8'));