Link to home
Start Free TrialLog in
Avatar of mrt1
mrt1

asked on

Output data to a local client directory

I've recently 'inherited' a web app written in CGI, which queries a database and displays the results on a browser page.

I need to add some functionality to allow the user to download the results of the query to their local drive. I'm not sure what format this file should be at the moment.....Excel would be perfect, but I'd settle for a csv file if that is easier.

How do I go about doing this?

Ideally I'd like to prompt the user to select a file location using a common dialog, and then have the query results saved to the appropriate file format in the appropriate location.

ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrt1
mrt1

ASKER

Application is written in Perl. Any advice how I access the contents of the current html page and ouptu these to Excel or a csv file?

I'm new to Perl, so any example would be appreciated.
Avatar of mrt1

ASKER

I've managed to get the export to Excel to work using the 'application/vnd.ms-excel' type (thanks for the help on this!). It is taking too long to download, though - I guess this is because the data has to be read from database, converted to HTML and then converted into Excel format.

I would rather download straight to a csv format, which should be faster and will get over Excel's row limit limitation.

What syntax do I need to do this? Is there a different content-type I can use?

I have a DB connection:
        my $dbh = DBI->connect($DBIPARAM,$user,$password,RaiseError=>1,PrintError=>1})

and a query to run ($query).

Can someone show me a rough outline of the code I need to create a .csv file of data on the client workstation?