By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,612 Members | 1,632 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,612 IT Pros & Developers. It's quick & easy.

Data download from PHP/MSSQL to Excel

P: n/a
I have a webpage that displays data from a SQL database in table
format. I found information on how to create a way to allow a user to
download this information to Excel using 'Header()' in the PHP code.

Header("Content-Type: application/vnd.ms-excel");
Header("Content-Disposition: attachment;
filename=\"filename.xls\"");

I setup a link on the display page that sends the variables needed for
the SQL query to a different PHP page and the link is targeted to a
bogus target window (target="excel") so that it doesn't change my
current display. This is meant for people who find the proper display
they want and then want to save it but also want to continue display
other data in the current window.

If the user clicks the link it then opens a browser window and prompts
the user with the typical IE download prompts, which is fine. But if
the user chooses to 'Save' the file to his/her pc and then goes
through the steps to save it, the browser window that was opened
doesn't automatically close. If the user chooses to open the .xls or
chooses to cancel the download, then the browser window closes just
fine.

Any suggestions as to how to alleviate this problem?
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
This is browser dependant and not PHP

"marty" <ma*********@adp.com> wrote in message
news:16**************************@posting.google.c om...
I have a webpage that displays data from a SQL database in table
format. I found information on how to create a way to allow a user to
download this information to Excel using 'Header()' in the PHP code.

Header("Content-Type: application/vnd.ms-excel");
Header("Content-Disposition: attachment;
filename=\"filename.xls\"");

I setup a link on the display page that sends the variables needed for
the SQL query to a different PHP page and the link is targeted to a
bogus target window (target="excel") so that it doesn't change my
current display. This is meant for people who find the proper display
they want and then want to save it but also want to continue display
other data in the current window.

If the user clicks the link it then opens a browser window and prompts
the user with the typical IE download prompts, which is fine. But if
the user chooses to 'Save' the file to his/her pc and then goes
through the steps to save it, the browser window that was opened
doesn't automatically close. If the user chooses to open the .xls or
chooses to cancel the download, then the browser window closes just
fine.

Any suggestions as to how to alleviate this problem?

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.