【发布时间】:2014-09-26 09:22:27
【问题描述】:
我有两个如下文件。
我想要做的是,我想在第一个文件中获取第二个文件内容,然后将其导出到 xls。
下面的代码有什么问题。
我的意图是 - 使用第一个 php 文件读取第二个 php 文件,然后 excel 将该内容导出到 C:/myfiles/test.xls 中的 .xls
index.php
<?php
$read_file = readfile("my_export_file.php");
$file = 'test.xls';
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
echo $read_file;
?>
my_export_file.php
<script type="text/javascript"> my javascript content</script>
<?php
include 'db.php';
$my_query = "mysql query to get the table content";
?>
<table>
<tr><td>.. mysql row content ..</td><td>.. mysql row content ..</td></tr>
<tr><td>.. mysql row content ..</td><td>.. mysql row content ..</td></tr>
<tr><td>.. mysql row content ..</td><td>.. mysql row content ..</td></tr>
</table>
有人可以帮我完成这项工作吗?
提前致谢。
问候, 金兹
【问题讨论】:
-
您应该在 my_export_file.php 中回显您的 html,然后将其包含在 index.php 中而不是 readfile 中
-
@rajeshujade - 你可以添加你的想法/cmets,这样它会更有帮助。
-
添加了答案。希望对您有所帮助。
-
与PHPExcel无关
标签: php html forms export-to-excel