ohh,
now thats nice, I was wondering if there was a way to avoid writing the
file...
you have just answered a couple of questions for me...
I thought about the idea of using the existing runmode, but this app will
eventually have a ton of screens with download buttons so I wanted a central
sub that can be passed parameters from any runmode to format and start
download of the correct data...
I have used your extra parameter idea before.. like on my login screen, I
pass it "failed" or "missing username or password" messages etc... it works
great.. the login screen reapears with a big red warning message in the
middle if they don't log in correctly. For this though, I want to make the
app as easy to extend as possible.. as the CEO tells me he wants it alot
bigger.
but still, I have alot more ideas now then I did before..
I love this list..... :-)
rgds
Frank
-----Original Message-----
From: Dan Coutu [mailto:suppressed
Sent: Wednesday, 12 February 2003 3:40 AM
To: suppressed
Subject: Re: [cgiapp] creating a .csv file...
Franki wrote:
> I need to put a link on the DB displays where they can download the data
in
> csv format (comma seperated values so the winblows newbies get an excel
icon
> appear when the download it.)
>
> Anyway, I don't want to create the file unless they are gonna use it..
> because it will take resources to create a file that might not be used,
and
> its slowish already.. (need to upgrade the server soon.)
>
> I thought about creating a runmode for the csv that receives the relevant
> query data from the runmode that refered to it... and does the query
again,
> this time printing to file while in the fetchrow loop... then print a
> download header and start the download...
>
I did something almost exactly like this a few weeks ago. Instead of a new
run mode I used a parameter on an existing run mode. The logic is like this:
I have a run mode that displays a list of details in an HTML table that
happens to look a lot like a spreadsheet display. At the bottom of the page
is a hyperlink (could be text or tied to a button or image, your choice)
that uses the same URL that brought me to the current run mode but with one
parameter different in order to dictate that the output should look like a
downloadable excel file instead of a web page. Specify the output header is
of type application/ms-excel and specify an attachment with a filename that
has an xls extension. It will magically show up as a download to the user
without redisplaying the current web page. To set the header I used this:
my $Output = CGI::header(-type => "application/ms-excel",
-attachment => $FileName);
before I added any other text to the $Output string that my run mode
returns. Since then I've seen mention in the pod docs that there is a
header_props method to CGI::Application that I had missed before. This is
probably the more proper way to setup the header.
BTW, you do not have to print to a file, that is a waste of time and
resources. Just throw it all into the output string and go.
--
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.