Very simple, look at the content, not much to say:
<?php
Set Title
$header [] = "ID";
$header [] = "Order";
$header [] = "mode";
$header [] = "Account";
$header [] = "Role id";
$header [] = "Role name";
$header [] = "ingot";
$header [] = "Amount";
$header [] = ' IP ';
$header [] = "Time";
$info [] = $header;
Set content
$tmp [1] = 1;
$tmp [2] = 2;
$tmp [3] = 3;
$tmp [4] = 4;
$tmp [5] = 5;
$tmp [6] = 6;
$tmp [7] = 7;
$tmp [8] = 8;
$tmp [9] = 9;
$tmp [10] = ' 2015 ';
$info [] = $tmp;
Filename
$file = Date ("Ymd_his", Mktime ()). CSV ';
Ini_set (' Memory_limit ', ' 1024M ');//Memory maximum occupancy
Header (' content-type:text/csv ');//Content Type
Header (' Content-type:text/vnd.ms-excel ');//Content Type
Header (' content-disposition:attachment;filename= '. $file);
$fp = fopen (' Php://output ', ' w ');//Open File
foreach ($info as $row) {
$fields = Array ();
foreach ($row as $val) {
$fields [] = Iconv (' utf-8 ', ' GBK ', $val);//Set encoding
}
Fputcsv ($fp, $fields);//write
}
Fclose ($FP);//Close
?>
How PHP exports data to Excel