DelphiFAQ Home Search:

Perl script on web server sends Excel file to browser

 

comments75 comments. Current rating: 3 stars (74 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 5 of 5, other pages: 1 2 3 4 [5]
2020-09-15, 07:50:26
anonymous from Germany  
rating
achat cialis meilleur site

[url= https://cialisverygo..m/]generic cialis[/url]
<a href=' https://cialisverygo..gt;generic cialis</a>

generic cialis one pill
2020-09-15, 08:09:07
anonymous from Germany  
rating
cialis pills in the usa

[url= https://cialisverygo..om/]cialis ohne rezept schweiz[/url]
<a href=' https://cialisverygo..>cialis 20mg generic cheapers</a>

cialis georgia
2020-09-15, 09:34:00
anonymous from Germany  
rating
buy cialis fast delivery aus

[url= https://cialisverygo..om/]follow link cialis 100[/url]
<a href=' https://cialisverygo..m/'>the best site usa cialis</a>

cialis eiaculazione precoce
2020-09-15, 11:21:36
anonymous from Germany  
rating
cialis bon compte

[url= https://cialisverygo..om/]cialis online store[/url]
<a href=' https://cialisverygo..>cialis to buy in new zealand</a>

is cialis made generically
2020-09-15, 15:00:24
anonymous from Germany  
rating
5 mg cialis lasts

[url= https://cialisverygo..m/]generic cialis online[/url]
<a href=' https://cialisverygo../'>look there rx cialis</a>

enter site cialis generic
2020-09-15, 16:34:55
anonymous from Germany  
rating
free cialis trial pack 20mg

[url= https://cialisverygoodn.com/]5 mg cialis lasts[/url]
<a href=' https://cialisverygo..>cialis 40mg 60mg</a>

buy cialis online cialis
2020-09-15, 17:07:27
anonymous from Germany  
rating
confronto levitra cialis onlin

[url= https://cialisverygo..om/]cialis forum doctissimo[/url]
<a href=' https://cialisverygo..om/'>is cialis made generically</a>

cialis order online india
2020-09-15, 18:15:39
anonymous from Germany  
rating
cialis seguridad socia

[url= https://cialisverygo..n.com/]buy cialis[/url]
<a href=' https://cialisverygo../'>what types of cialis are there</a>

cialis 5mg best time use
2020-09-15, 21:04:45
anonymous from Germany  
rating
wow look it cialis in canada

[url= https://cialisverygo..escription cialis canada[/url]
<a href=' https://cialisverygo..>french over the counter cialis</a>

cialis 5 mg baratos
2020-09-15, 21:35:09
anonymous from Germany  
rating
que es el cialis de 5 mg

[url= https://cialisverygo..n.com/]buy generic cialis[/url]
<a href=' https://cialisverygo..gt;generic cialis farmacia</a>

cialis online 24 ore
2020-09-15, 23:21:16
anonymous from Germany  
rating
cialis 10 mg lilly preis

[url= https://cialisverygoodn.com/]5 mg cialis lasts[/url]
<a href=' https://cialisverygo..gt;acheter cialis pas cher forum</a>

cialis generika preisvergleich
2020-09-16, 02:54:51
anonymous from Germany  
rating
only for you cialis 100mg

[url= https://cialisverygo..n.com/]buy generic cialis[/url]
<a href=' https://cialisverygo..'>cheap cialis</a>

buy cialis fast delivery aus
2020-09-16, 03:51:50
anonymous from Germany  
rating
cialis boutique

[url= https://cialisverygo..om/]cialis online[/url]
<a href=' https://cialisverygo..>online cialis</a>

cialis 5mg baratos
2020-09-16, 05:35:11
anonymous from Germany  
rating
look there cheap fast cialis

[url= https://cialisverygo..om/]cialis without prescription uk[/url]
<a href=' https://cialisverygo..'>cheap cialis online</a>

cvs cialis generic
2020-09-16, 11:35:33
anonymous from Germany  
rating
gel viagra thailand

[url= https://viagrahuupup.com/]buy viagra[/url]
<a href=' https://viagrahuupup..>viagra generico miglior</a>

viagra gold for sale
You are on page 5 of 5, other pages: 1 2 3 4 [5]

 

 

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: