Hi,

I am trying to save my query results into MS Excel format by using the following code.

It works on the 1st attempt, but however when i tried to save it again by making another query, i received this warning message: Cannot modify header information - headers already sent by (output started at C:\Program Files\EasyPHP5.3.0\www\phpexcel3.php:178) in C:\Program Files\EasyPHP5.3.0\www\phpexcel3.php on line 256

Can anyone able to advise me where is my mistake is? Cheers

my header script is :

header("Content-type: application/octet-stream");

# replace excelfile.xls with whatever you want the filename to default to
header("Content-Disposition: attachment; filename=excelfile.xls");
header("Pragma: no-cache");
header("Expires: 0");

your script is echoing something before the headers are sent, and that's why you hit with this error.
Just echo something like "test" just above the headers you are trying to modify and you will see what is being echoed before your header, check source

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.