php查询生成的报表如何存储为文本

来源:百度知道 编辑:UC知道 时间:2024/06/14 16:30:17
网页上输入查询的关键字, 然后再屏幕上输出查询后的表格, 我想在旁边有个选项, 可以把看到的这个表格保存为文本文件或者excel, 文件.
怎么可以实现呢?
谢谢. 在线等啊.

下面是我网站上的生成EXCEL并提示进行下载的程序源码,我这是一个通用工具,使用statement参数作为SQL语句:

<?php
set_time_limit(300);
$head_str='';
$tail_str='';

if (isset($_REQUEST["statement"])){//执行提交的命令
//输出表头
header('Content-type: application/excel');
header('Content-Disposition: attachment; filename="mysql.xls"');
echO <<<END
<?xml version="1.0" encoding="GBK"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProper