No need to use fputcsv function to generate reports. Just set the corresponding format and HTTP header information to generate the report. Attached code:
<?php header("Content-type: application/vnd.ms-excel; charset=utf-8"); header("Content-Disposition: attachment; filename=excel.xls"); $data = "分类销售统计\t\n"; $data .= "排名\t产品大类\t销售额(万)\t销售占比\t单品数量\n"; if (EC_CHARSET == 'utf-8') { echo ecs_iconv(EC_CHARSET, 'GB2312', $data); } else { echo $data; } ?>
Note: The character conversion step can be omitted according to actual needs.