DelphiFAQ Home Search:

Perl script on web server sends Excel file to browser

 

comments195 comments. Current rating: 2 stars (194 votes). Leave comments and/ or rate it.

Question:

I need to have my web site generate an Excel worksheet on the fly (a database export) and send it to the user's webbrowser. How can I do that?

Answer:

The following assumes that you export a simple sheet containing strings and numbers, no formulas.

In this case, you can generate a CSV file (comma separated values) and set the mime type to applicatioon/octet-stream.

If you perl script is called as /cgi-bin/exportcsv.pl then the downloaded file will by default be named

exportcsv.pl.xls (using alternative mime type application/vnd.ms-excel)

To suggest a specific file name (other than the script name, use the Content-Disposition header field. This field allows you to provide other information as well, e.g.

- creation-date
- modification-date
- read-date
- size

Note:
The size parameter indicates just an approximate size of the file in octets. It does not have to be the exact size. This information can be used by the client software (web browser) to pre-allocate space before attempting to store the file, or to determine whether enough space exists.

For the full syntax, see RFC 2183

# alternative 1:
# sending a file simply as an Excel
print "Content-type: application/vnd.ms-excel\n";
print "Content-Disposition: attachment;filename=users.csv\n\n";

# alternative 2:
# sending a CSV file and suggesting 'users.csv' as the file name
print "Content-type: application/octet-stream\n";
print "Content-Disposition: attachment;filename=users.csv\n\n";

# now dump the data
# all values are enclosed by " in case the 
# strings contain a comma
# this dumps 2 rows with 2 columns each
print '"1","Test, first one"' . "\n";
print '"2","Test, last one"' . "\n";


Content-type: text/html

Comments:

You are on page 13 of 13, other pages: 1 2 3 10 11 12 [13]
2019-07-02, 04:43:23
anonymous from Russian Federation  
rating
[url= https://allopurinolz..llopurinol online purchase[/url] [url= https://femaleviagra..4.com/]buy female viagra[/url] [url= https://generictadal..m/]generic tadalafil[/url] [url= https://buydiflucan.com/]buy diflucan without prescription[/url]
2019-07-02, 05:03:53
anonymous from Russian Federation  
rating
2019-07-02, 07:09:10
anonymous from Russian Federation  
rating
[url= https://wellbutrin30..wellbutrin order online[/url] [url= https://generictadal..m/]generic cialis tadalafil 20mg[/url] [url= https://femaleviagra..om/]female viagra[/url] [url= https://buydiflucan.com/]buy diflucan over the counter[/url] [url= https://doxycycline0..oxycycline hyclate 100 mg[/url] [url= https://atenolol25.c../]atenolol 50 mg[/url] [url= https://hydrochlorot..m/]generic hydrochlorothiazide[/url] [url= https://azithromycin..ithromycin 250 mg tablets[/url] [url= https://cafergot100.com/]buy cafergot online[/url] [url= https://lisinoprilbuy.com/]buy lisinopril online[/url] [url= https://allopurinolz..inol[/url] [url= https://vardenafilbuy.com/]buy vardenafil canada[/url] [url= https://atarax10.com/]generic for atarax[/url] [url= https://xenical120mg..ical[/url] [url= https://levitrasale.com/]buy levitra online[/url]
2019-07-02, 07:09:48
anonymous from Russian Federation  
rating
2019-07-02, 11:02:35
anonymous from Russian Federation  
rating
[url= https://tetracycline..tracycline antibiotics[/url]
2019-07-02, 13:58:41
anonymous from Russian Federation  
rating
[url= https://generictadal..m/]generic tadalafil 20mg[/url] [url= https://levitrasale...m/]levitra online[/url] [url= https://hydrochlorot..zide[/url] [url= https://wellbutrin30..wellbutrin adhd[/url] [url= https://cafergot100.com/]cheap cafergot[/url] [url= https://xenical120mg.com/]buy xenical[/url] [url= https://vardenafilbu..m/]generic vardenafil online[/url] [url= https://tetracycline..tracycline antibiotic[/url] [url= https://doxycycline0..oxycycline 100 mg[/url] [url= https://femaleviagra..om/]viagra for females[/url] [url= https://atarax10.com/]atarax 50 mg[/url] [url= https://sildalis120...m/]generic sildalis[/url] [url= https://buydiflucan.com/]buy diflucan online[/url] [url= https://sildenafil10..0.com/]buy sildenafil citrate[/url] [url= https://allopurinolz..m.com/]buy allopurinol online[/url]
2019-07-02, 15:36:53
anonymous from Russian Federation  
rating
2019-07-02, 18:11:17
anonymous from Russian Federation  
rating
2019-07-02, 18:31:02
anonymous from Russian Federation  
rating
[url= https://azithromycin..com/]order azithromycin online[/url] [url= https://xenical120mg.com/]buy xenical[/url] [url= https://buydiflucan.../]diflucan prescription[/url] [url= https://generictadal..m/]generic tadalafil 20mg[/url] [url= https://vardenafilbu..vardenafil buy[/url] [url= https://wellbutrin30..wellbutrin sr 150[/url] [url= https://atarax10.com/]generic for atarax[/url] [url= https://tetracycline..5.com/]buy tetracycline online[/url] [url= https://doxycycline0..oxycycline online[/url] [url= https://lisinoprilbuy.com/]no prescription lisinopril[/url]
2019-07-02, 18:37:26
anonymous from Russian Federation  
rating
[url= https://levitrasale...m/]levitra online[/url] [url= https://vardenafilbuy.com/]buy vardenafil[/url] [url= https://tetracycline..tracycline online[/url] [url= https://femaleviagra..4.com/]buy female viagra online[/url] [url= https://doxycycline02.com/]buy doxycycline online[/url]
2019-07-02, 21:20:17
anonymous from Russian Federation  
rating
[url= https://buydiflucan.com/]buy fluconazole[/url]
2019-07-11, 12:20:37
anonymous from Ukraine  
rating
best online canadian pharmacy [url= http://canadianonli..com/]vipps approved canadian online pharmacy[/url] canadian online pharmacy cialis <a href=' http://canadianonli..'>vipps approved canadian online pharmacy</a> viagra online http://canadianonli..ydazc.com/
2019-07-11, 14:10:04
anonymous from Ukraine  
rating
best canadian online pharmacy [url= http://canadianonli../]canadian online pharmacy reviews[/url] canadian online pharmacy viagra <a href=' http://canadianonli..legitimate canadian online pharmacy</a> buy cialis online canadian pharmacy http://canadianonli..ydazc.com/
2019-07-11, 19:55:43
anonymous from Ukraine  
rating
online canadian pharmacy reviews [url= http://canadianonli..com/]cheap viagra online canadian pharmacy[/url] online canadian pharmacy reviews <a href=' http://canadianonli..t;canadian pharmacy online cialis</a> canadian online pharmacy http://canadianonli..ydazc.com/
2019-07-12, 00:29:34
anonymous from Ukraine  
rating
cheap viagra online canadian pharmacy [url= http://canadianonli..com/]cheap canadian pharmacy online[/url] canadian pharmacy online cialis <a href=' http://canadianonli../#'>buy viagra</a> online canadian pharmacy http://canadianonli..ydazc.com/
You are on page 13 of 13, other pages: 1 2 3 10 11 12 [13]

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: