/* * $lists 二维数组 */ public function xlsx($lists) { //生成文件名 $date = date("Y-m-d_H:i:s", time()); $fileName = "XXXX_" . $date . ".xlsx"; //头部标题 $xlsx_header = array('序号', 'UID'); ob_get_clean(); ob_start(); echo implode("\t", $xlsx_header),"\n"; $num = 0; foreach ($lists as $key => $value) { $data = array(); //序号 $data[] = $num; //UID $data[] = $value['uid']; $data[] = $value['useruntwo']; echo implode("\t", $data),"\n"; } header('Content-Disposition: attachment; filename='.$fileName); header('Accept-Ranges:bytes'); header('Content-Length:' . ob_get_length()); header('Content-Type:application/vnd.ms-excel'); ob_end_flush(); }
php导出数据xlsx
最新推荐文章于 2024-03-07 17:08:51 发布