Data download from PHP/MSSQL to Excel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • marty

    Data download from PHP/MSSQL to Excel

    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=\"file name.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?
  • Hi Ho

    #2
    Re: Data download from PHP/MSSQL to Excel

    This is browser dependant and not PHP

    "marty" <marty_elder@ad p.com> wrote in message
    news:166bf1ae.0 404210549.313ad 03b@posting.goo gle.com...[color=blue]
    > 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=\"file name.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?[/color]


    Comment

    Working...