[nycphp-talk] Creating file for download on the fly?
Jeremy Hise
jhise at linuxforbusiness.org
Fri Jul 26 14:46:04 EDT 2002
One thing that I have done is create an HTML table as usual, no graphics
or anything like that. But at the top of the page before you output
anything to the browser, you can do:
header("Content-Type: application/excel");
If you are on a windows machine and have excel installed and are using
IE, excel will open up and convert the thing to a basic spreadsheet.
Then the user could save this file if they want.
The only problem I've had in the past is the user trying to save the
file on the server when they have the excel open in front of them.
You may want to check that "application/excel" part. I may be wrong.
Could be "...ms-excel" or something. Shouldn't be tough to look up on
the web though.
Hope this is helpful,
hise
On Fri, 2002-07-26 at 13:22, Edgar Reyes wrote:
> Hello,
>
> Well I don't know if you are running on Windows or on Unix server but I if
> you are running an a windows platform, you can change the MIME type on the
> results page and have it come up on an excel sheet and if they want to save
> it they can just go to file save as and save the results on their computer.
>
> Hope this helps.
> ----- Original Message -----
> From: "Freedman, Tom S." <tfreedma at ubspw.com>
> To: "NYPHP Talk" <talk at nyphp.org>
> Sent: Friday, July 26, 2002 10:15 AM
> Subject: [nycphp-talk] Creating file for download on the fly?
>
>
> > Hi all, I've been a lurker for a couple months as I've been learning PHP,
> > and many of your suggestions have been really helpful. I was hoping
> someone
> > might have an idea on how to tackle an issue I haven't been able to find
> any
> > info on.
> >
> > I'm currently working on a new version of a departmental intranet website.
> > I have a database, and offer the users a search page that lets them query
> it
> > in a variety of ways. The new results page is not laid out in a grid, as
> > the old one was (we've added a lot of new fields, and the grid would be
> too
> > packed). Some users have requested the ability to download the data for
> > import into Excel (they used to just copy and paste the table in). I've
> > figured out how to create a .csv file, and I could, theoretically, create
> > one every time someone runs a query, save it in a temp directory, and
> > include a link to it on the webpage. We'd have to run a cleanup routine
> > every night, though, to delete all these .csv's on the server. It seems
> > really clumsy to me. What I'd like to do is put a link on the result page
> > that, when clicked on, builds the .csv right then and offers it to the
> user
> > for download. Is this feasible, or should I just go with the temp
> directory
> > full of reports?
> >
> > Thanks in advance,
> > Tom
> >
> >
> >
> >
>
>
>
>
More information about the talk
mailing list