?
不需要用到?fputcsv 函数来生成报表。只需设置相应的格式和HTTP头信息,就能够生成报表了。附上代码:
?
class="php" name="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; } ?>
?
说明:字符转换这一步骤根据实际需要可以省略。
?
?原文链接:http://woqilin.blogspot.com/2016/06/php-http-excel.html