[thelist] MySQL to Excel Problem

Dougal Campbell dougal at gunters.org
Wed May 1 12:19:01 CDT 2002


On Wed, 1 May 2002, Jay Blanchard wrote:

> Howdy all!
>
> Some of my users want Excel reports from MySQL databases, so I have done the
> following with PHP;
>
> <!--BEGIN CODE-->
> <?
> header("Content-Type:  application/x-excel");
> header("Content-Disposition: inline;
> filename=\"excel.xls\"");
> [....]
>
> If I name the file with a .xls extension it displays the code in the excel
> worksheet in the browser. If I name the file with the .php extension it
> opens Excel seperately, gives me a file download option (I click 'Open') and
> then asks me to tell it what created the file, so I pick Excel. Then the
> data is displayed  properly in the Excel worksheet, outside of the browser.
> I want the file to open an Excel worksheet in the browser (IE, on an
> Intranet). Is there something I am missing?

Internet Explorer has a nasty habit of ignoring Content-Type and
Content-Disposition headers, and relying instead on what it thinks the
file extension is. You might be able to work around it if you can use
PATH_INFO and squiggle things around in your app to generate URLs like
  http://server/excelgen.php/foobar.xls


--
Ernest MacDougal Campbell III, MCP+I, MCSE <dougal at gunters.org>
http://dougal.gunters.org/             http://spam.gunters.org/
  Web Design & Development:  http://www.mentalcollective.com/
       This message is guaranteed to be 100% eror frea!




More information about the thelist mailing list