HTML::Clean is a good idea... I had resorted to not using indentation.
Thanks!
-Dave
----- Original Message -----
From: "Martijn van den Burg" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 12, 2002 2:48 AM
Subject: Re: [htmltmpl] Downloading data to file. How?
> Hi,
>
> Thanks for the idea, it works well and it doesn't increase the number of
> templates.
>
> The user selects the download button, the query is run again and the
output
> is processed by H::T with a 'plaintext' parameter. The resulting 'excel'
> output is run through HTML::Clean to remove empty lines and superfluous
> spaces created by my indenting the template.
>
> The resulting output is written to a temporary file and mailed to the user
as
> an attachment (using Mail::Sendmail).
>
> On Tuesday 05 March 2002 16:40, David Ferrance wrote:
> > Definitely don't use option 2-- it is (basically) equivalent to option 1
> > but with more work.
> >
> > Methods 1 and 2 both potentially open you up to malicious bad people
seeing
> > other
> > people's results.
> >
> > How hard are the queries? If you can afford to run them twice, you
might
> > do what I did
> > in this situation. I have only one template, with this structure:
> >
> > <TMPL_IF NAME="EXCEL">
> > <pre>
> > blah,blah,csv,blah
> > </pre>
> > <TMPL_ELSE>
> > <html>
> > <p>words words words</p>
> > </html>
> > </TMPL_IF>
> >
> > So in the HTML I have a link to the same PL file, but this time with an
> > extra flag to tell it
> > to do $t->param(EXCEL=>1), and the output is something they can save
from
> > their browser
> > and import into excel.
> >
> > None of it is terribly elegant, but if you can afford to run the query
> > twice, it _does_
> > simplify the code.
> >
> > -Dave
> >
> > PS I am hoping one of you posts the pretty way to do this.
> >
> >
> > ----- Original Message -----
> > From: "Martijn van den Burg" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED] >
> > Sent: Tuesday, March 05, 2002 10:39 AM
> > Subject: [htmltmpl] Downloading data to file. How?
> >
> > > Hi,
> > >
> > > Problem: I want the $USER to have the possibility to download the data
> >
> > that
> >
> > > is displayed (using H::T) in his browser to a file in his own
directory.
> > > Without the fancy HTML formatting. I'm talking about tables with
numbers
> > > obtained from a MySQL database.
> > >
> > >
> > > Purpose: data download to, eg. M$ Excel, for further manipulation.
> > >
> > >
> > > Precondition: I'd really like to reuse the same datastructures I now
send
> >
> > to
> >
> > > H::T.
> > >
> > >
> > > Possible solutions:
> > >
> > > (1) Always save each query output also to file on the webserver (with
a
> > > unique ID) using a dedicated 'ASCII' template and
> >
> > $template->ouput(print_to
> >
> > > => *STDOUT) and then provide the $USER with a d/l link for that unique
> >
> > file.
> >
> > > Instead of table formatting I'd use CSV formatting.
> > >
> > > Pro: relatively easy to do
> > > Con: pollution of the webserver: need to remove 'stale' files
> > >
> > > (2) Don't use H::T and instead make separate subroutines for each
> > > dataset. Downloading them to the user with something like this:
> > >
> > > print $query->header('-type'=>'application/octet-stream');
> > > open (FILE, "<${docdir}/${file_name}") or fatal_error("$!\n");
> > > foreach (@lines_of_formatted_data) {
> > > print FILE "$_\n";
> > > }
> > > close (FILE);
> > >
> > >
> > > (3) Use a CPAN module someone else wrote but which is as yet unknown
to
> >
> > me.
> >
> > > Your input is much appreciated.
> > >
> > > Martijn
> > >
> > > --
> > > +----------------------------------+
> > > Martijn van den Burg
> > > ASML, CS PPC Inform@tion Systems
> > > Voice: +31 (0)40 268 3856
> > > +----------------------------------+
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
>
> --
> +----------------------------------+
> Martijn van den Burg
> ASML, CS PPC Inform@tion Systems
> Voice: +31 (0)40 268 3856
> +----------------------------------+
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]