单行线 使用fopen(“test.xls”)创建xls。
第二条路
我用puting生成xls
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 header ("Pragma: no-cache"); header("Expires: 0"); header('Content-Transfer-Encoding: none'); header("Content-Disposition: attachment; filename=\"test.xls\""); header("Content-Type: application/vnd.ms-excel"); foreach () { echo contents to the file }
这两种生成文件的方法有什么不同吗。
有什么不同。
第一种方法是在服务器文件系统中创建文件,然后通过浏览器提供。文件会保留在那里(除非您有额外的代码可以在以后删除它)。
第二种方法似乎没有在文件系统中创建实际的文件,而是动态生成数据,然后浏览器将其保存到文件中。