我有两个文件,如下所示。使用php文件和excel导出读取php文件
我想要做的是,我想获取第一个文件中的第二个文件内容,然后将其导出到xls。
下面的代码有什么问题。
我的内涵是 - 读取使用的第一个PHP文件中的第二个PHP文件,然后Excel导出的内容添加到的.xls在C:/myfiles/test.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>
有人能帮助我完成这件事。
在此先感谢。
问候, Kimz
你应该在my_export_file.php中回显你的html,然后把它包含在index.php而不是readfile中 – 2014-09-26 09:25:27
@rajeshujade - 你可以添加你的想法/评论,这样会更有帮助。 – user3350885 2014-09-26 09:40:58
已添加答案。希望它会帮助你。 – 2014-09-26 09:48:02