DelphiFAQ Home Search:

Perl script on web server sends Excel file to browser

 

comments225 comments. Current rating: 2 stars (222 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 15 of 15, other pages: 1 2 3 12 13 14 [15]
2019-08-14, 00:46:34
anonymous from Russian Federation  
rating
[url= https://hevymarufepu..ilex[/url] [url= https://duwiconegemy..agyl[/url] [url= https://cytanokexihi..]aciclovir cream[/url] [url= https://zecojylujixy..erene/hctz caps[/url] [url= https://cidazojaju.g..]trazodone drug[/url] [url= https://qapebygiquxo.tk/]buy benicar[/url] [url= https://vuzefyxe.ml/]where can i where to buy cafergot for migraines[/url] [url= https://ikekidyt.tk/]diovan erectile dysfunction[/url] [url= https://gidatebikapy.tk/]buy xenical[/url] [url= https://witesyfy.cf/..domethacin 25 mg[/url]
2019-08-14, 03:43:00
anonymous from Russian Federation  
rating
2019-08-14, 06:14:53
anonymous from Russian Federation  
rating
[url= https://usyxynyzoh.tk/]generic for cialis[/url] [url= https://fanyfywu.tk/]buy kamagra oral jelly[/url] [url= https://orohyqur.tk/]skelaxin pill[/url] [url= https://ofyzozef.tk/]valtrex cost[/url] [url= https://okefuvyn.ml/]tadalafil for sale[/url]
2019-08-14, 06:45:50
anonymous from Russian Federation  
rating
[url= https://olevucyj.ml/]buy crestor[/url]
2019-08-14, 06:50:33
anonymous from Russian Federation  
rating
[url= https://ozilizehyx.tk/]buy chloromycetin[/url] [url= https://lorekuqydu.t..]tadalafil dosage 40 mg[/url] [url= https://jakahokadiwa..k/]proscar 5mg[/url] [url= https://edexyfiqoj.t..]plaquenil eye damage[/url] [url= https://yfalipozovec.tk/]buy lexapro cheap no prescription[/url] [url= https://uvojicuxumuk..ilex[/url] [url= https://ziloxutofuji..cephalexin buy online[/url] [url= https://dyninaqy.tk/...org[/url] [url= https://ezedyqav.tk/..wellbutrin xl[/url] [url= https://ytevoquwigeq..k/]precose weight loss[/url] [url= https://hevymarufepu.ml/]pilex without prescription[/url] [url= https://ezolakegixot.tk/]buy septilin[/url] [url= https://epobahuved.tk/]mentat without prescription[/url] [url= https://esuriguneh.tk/]alli prices[/url] [url= https://jijyzyniwu.tk/]zoloft medication[/url] [url= https://modabyke.tk/]cost of avodart[/url] [url= https://myxyhepamevu..ga/]flagyl antibiotic[/url] [url= https://ihixofunim.tk/]benicar hct price[/url] [url= https://hivomatu.ml/]buy acticin[/url] [url= https://rabagupyhydu..tk/]viagra over counter[/url]
2019-08-14, 07:15:25
anonymous from Russian Federation  
rating
2019-08-14, 07:15:40
anonymous from Russian Federation  
rating
[url= https://upabylixyg.tk/]buy flonase[/url] [url= https://orusobunasaj.gq/]zyban drug[/url] [url= https://adebunavaz.t..utol[/url] [url= https://elogaxizor.gq/]toprol xl 50 mg[/url] [url= https://roqavogujy.cf/]cialis tadalafil[/url] [url= https://wypakige.tk/]where can i buy alavert[/url] [url= https://ojanewaxamad..k/]generic for atarax[/url] [url= https://tivexycahysa.tk/]buy cystone[/url] [url= https://yvuwyqytoqyx..k/]generic mestinon[/url] [url= https://izyryvatew.ga/]buy trecator sc[/url]
2019-08-14, 10:07:32
anonymous from Russian Federation  
rating
2019-08-14, 10:11:47
anonymous from Russian Federation  
rating
[url= https://pelefuvucyqi../]canadian cialis online[/url] [url= https://emonipun.tk/..yrel[/url] [url= https://laqulobywa.t..]synthroid 50 mcg[/url] [url= https://acybetysyt.tk/]buy advair[/url] [url= https://rozubyxupopa.gq/]buy adalat[/url] [url= https://axykapuh.tk/]prinivil generic[/url] [url= https://ozilizehyx.t..oromycetin online[/url] [url= https://ypyrelygax.t..]tadalafil 40 mg[/url] [url= https://ohehorysoh.ga/]buy clonidine online[/url] [url= https://jyjitiryvewo..tk/]atarax for children[/url] [url= https://wuxyryhyhido..lisinopril 10mg tablets[/url] [url= https://utozodysevit../]seroquel xr[/url] [url= https://axixesawan.cf/]female viagra for women[/url] [url= https://vixicivubi.tk/]generic vasotec[/url] [url= https://bukamiqyqu.tk/]viagra soft tablets[/url] [url= https://ocucineqobes..k/]cystone without prescription[/url] [url= https://wizululykama../]finpecia without prescription[/url] [url= https://uwycucel.tk/]buy rumalaya[/url] [url= https://hapomalelacy..]anafranil clomipramine[/url] [url= https://dydorydacibo..k/]benicar 20 mg cost[/url] [url= https://vaqivaxuxo.tk/]buy geriforte[/url] [url= https://aqyjukesag.m..vardenafil levitra[/url] [url= https://calikatoki.t..line[/url] [url= https://lyniqycawegy..fluoxetine cap 20mg[/url]
2019-08-14, 12:40:33
anonymous from Russian Federation  
rating
2019-08-14, 12:56:17
anonymous from Russian Federation  
rating
2019-08-14, 13:46:21
anonymous from Russian Federation  
rating
2019-08-14, 13:49:41
anonymous from Russian Federation  
rating
2019-08-14, 14:10:56
anonymous from Russian Federation  
rating
2019-08-14, 15:04:07
anonymous from Russian Federation  
rating
You are on page 15 of 15, other pages: 1 2 3 12 13 14 [15]

 

 

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: