I haev output some data using PHP to Excel. It works fine but I have used HTML tags instead of tabs and new line breaks, to improve the interface.

When I go to save the file it defaults to save as a webpage rather than an excel document.

is there something extra i have to pass over in the headers to deault it to excel document

    You may want to try setting setting the Content Type attributes in the header. You can do this by putting this in your php file (before outputting anything mind you):

    header("Content-type: application/x-msexcel");

    *Also add this so it saves it as the right filename:

    header("Content-Disposition: inline; filename=filename.extension");

    For me when this is set it automaticaly asks you to save the document instead of displaying the information in the browser.

      yes i have done that - It will prompt to open or save as - if i press save as it will save as excel document. But if I open the document into excel and then go to save as it will prompt to save as a webpage.

      I'm starting to think I can't do anything as it is an excel thing rather than a passing information thing

        when excel sees the html tags it thinks it is a webpage rather than an excel file.

        thats the reason for that behaviour

          Yes i kinda got that but is there anything i can pass across to say it's an .xls file

            Write a Reply...