>>> "Moon, John" <[EMAIL PROTECTED]> 2/26/2004 3:42:26 PM >>> >-----Original Message----- >From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] >Sent: Thursday, February 26, 2004 3:03 PM >To: Moon, John; CGI Beginners >Subject: RE: What are you really trying to do? - document type = >application/vnd.ms-excel
.... <thread snipped> ... >I haven't used them before, but you may want to look into: > >http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-0.42/WriteExcel.pm >http://search.cpan.org/~tmtm/Spreadsheet-WriteExcel-FromDB-0.09/lib/Spreadsheet/WriteExcel/FromDB.pm > >Presumably your CGI can use one of the above to generate the file on the >fly then just print your header and the contents of the file, you may >even be able to bypass the local temp storage but I didn't check real >closely. > >Good Luck, > >http://danconia.org > > >> >> -----Original Message----- >> From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] >> Sent: Thursday, February 26, 2004 1:51 PM >> To: Moon, John; CGI Beginners >> Subject: Re: document type = application/vnd.ms-excel >> >> > I am trying to generate a web page with : >> > print $q->header("application/vnd.ms-excel"), >> > >> > This tries to launch Excel but I get the error: >> > "File cannot be opened because: A declaration was not closed Line 1, >> > Position 1 <" >> > >> > When I use: >> > print $q->header("text/html"), >> > >> > The page displays correctly and I do not see any "open" or "unclosed" >> > HTML... >> > >> >> If you print an excel header then you have to print excel formatted >> output, not HTML. There is no automatic conversion on either side of >> the connection (at least without a pretty nice plugin that I don't think >> has been written yet). There is a chance you could print an excel >> header and then output comma delimited data but I would be surprised if >> excel is that smart. >> >> What are you really trying to do? >> >> http://danconia.org >> >> -- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> <http://learn.perl.org/> <http://learn.perl.org/first-response> >> >> >> >Thanks to all who replied. > >Looks like I start writing duplicate programs... > >jwm Not neccessarily - we've used the CSV file option in the same CGI script, without any additional Perl Modules. On pages where users want to also download data into Excel, we - place a link to 'download this', e.g.: <A HREF="xref.cgi?save=yes&server=$environment">Download</A> - when the SAVE parm is encountered in the script, it execs the SQL and produces a file on the server in a specific temp space for this file named like 'xref.cvs', with the usual ... open,flock,print,close stuff - the last thing it does is put up new HTTP headers such as: Content-type: text/csv Cache-control: nocache Location: http://$host/xref.csv ... which forces a redirect to that location. In our environment, this solution has met the needs for those infrequent users who occasionally want to play with the data themselves in Excel. If their browser mime helpers are set correctly, the only action they have to take is to click a Save or Open dialog box, and then the data is loaded into Excel as a CSV very nicely. They then have to know what to do when Excel asks them if they save it (xls vs. csv something something). This may not be an option if your users have not been gifted with "clue", but it meets our needs here. If you have heavily hit pages where users are simultaneously accessing and downloading, you'd need to name the temp CSV files uniquely (process-id, e.g.). We also have some scripts that remove old CSV files from the temp space when they start up, so disk is managed too. HTH - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - John Mooney llbean.com Information Services [EMAIL PROTECTED] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>