回声后在PHP中输出Excel文件 [英] Output Excel file in PHP after echo

查看:61
本文介绍了回声后在PHP中输出Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI

我正在尝试在results.php中显示数据库的结果.在同一文件中,所有数据都显示在当前网页中之后,我将放置一个按钮,根据此结果创建文件以生成Excel文件.

I am trying to display results from a database in results.php. In the same file, after all the data has been displayed in the current webpage,I am placing a button to create a file based on this results to produce a Excel file.

我不确定该怎么做.我已经尝试过了,但是它说您必须在任何回显之前强制下载excel文件,但是我想显示并产生一个excel文件.这可能吗?或者我想念什么吗?有人可以让我知道如何正确执行此操作吗?

I am not sure how to do this. I have tried but it says you have to force excel file download before any echo, but I want to display as well as produce an excel file. Is this possible or am I missing something? can anyone please let me know how to do this correctly?

推荐答案

您可能会遇到"Header allready set"错误.您需要将两个步骤分开才能完成该工作.显示的第一步,而用于Excel文件创建和下载的一步.

You're probably faceing an 'Header allready set' error. You need to separe the two steps in order to make that work. One step for displaying and one for excel file creation and downloading.

另一方面,您也可以将数据显示和excel创建结合起来,并最终显示下载链接.

On th other hand you could combine the data display and excel creation too and eventually display a download link.

就像鲍金在黑暗中一样,让我们​​知道您想走哪条路,我们将为您提供帮助...

Just pokin in the dark, let us know which way you wanna go and we'll be helping you along...

这篇关于回声后在PHP中输出Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆