点击(此处)折叠或打开
-
$header = array(
-
'id' => 'ID',
-
'create_time' => '提交时间'
-
);
-
header('Content-Type: application/vnd.ms-excel');
-
header('Content-Disposition: attachment;filename="明细.csv"');
-
header('Cache-Control: max-age=0');
-
$fp = fopen('php://output', 'a');
-
//导出表头
-
$header_arr = array();
-
foreach( $header as $key => $val ) {
-
$header_arr[] = mb_convert_encoding($val,'gbk','utf8');
-
}
-
fputcsv($fp, $header_arr);
-
-
$start = 0;
-
$offset = 5000;
-
if( $count['num'] > 0 ) {
-
while( true ) {
-
ob_flush();
-
flush();
-
$args['start'] = $start;
-
$args['offset'] = $offset;
-
$info = $this->get_list($args);
-
if( !empty($info) ) {
-
foreach( $info as $row ) {
-
$one_row = array();
-
foreach( $header as $key => $val ) {
-
$one_row[]=mb_convert_encoding((string)$row[$key],'gbk','utf8');
-
}
-
fputcsv($fp, $one_row);
-
}
-
} else {
-
break;
-
}
-
$start +=5000;
-
}
- }