set_time_limit(0);
$a = function () {
for ($i = 0; $i < 500000; $i++) {
$arr = [
'appended' . $i,
'appended',
'appended',
'appended',
'appended',
'appended',
'2022-07-15 00:00:00',
'appended',
'异常少油',
'appended',
'appended',
'appended',
'油耗统计',
'appended',
'添加剂',
];
yield $arr;
}
};
$fileName = uniqid();
header('Content-Encoding: UTF-8');
header("Content-type:application/vnd.ms-excel;charset=UTF-8");
header('Content-Disposition: attachment;filename="' . $fileName . '.csv"');
file_put_contents('php://output', chr(0xEF) . chr(0xBB) . chr(0xBF), FILE_APPEND);
foreach ($a() as $k => $v) {
file_put_contents('php://output', implode(",", $v) . PHP_EOL, FILE_APPEND);
}
php大数据导出
最新推荐文章于 2024-05-11 18:07:59 发布