Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Force Download to a .xls file

by edan (Curate)
on Jan 04, 2005 at 12:15 UTC ( #419216=note: print w/ replies, xml ) Need Help??


in reply to Force Download to a .xls file

I use the following incantation, with success:

print $cgi->header( '-type' => "application/octet-stream; name=$file", '-Content-Disposition' => "attachment; filename=$file", '-Content-Transfer-Encoding' => "binary");

Note that $file is the basename, with no path - maybe that's all that's messing you up. In your case, it should just be "$xlsfile" I think.

--
edan


Comment on Re: Force Download to a .xls file
Download Code
Replies are listed 'Best First'.
Re^2: Force Download to a .xls file
by existem (Sexton) on Feb 16, 2005 at 12:39 UTC

    Just as a little side not to all this, i've finally managed to get it to work using this notation.

    print "Content-type: application/vnd.ms-excel\n"; print "Content-Disposition: attachment; filename=$filename\n"; print "\n"; open TMP, "$directory/$filename" or die "Error message here: $!\n"; binmode TMP; binmode STDOUT; print <TMP>;

    Please note that the first bit just uses the basename of the file, so without the whole directory path. Whereas the second bit uses the $directory path so it's absolute on the file system. This little thing had me stumped for a while there, so thought i'd share incase others have the same problem.

    Best of luck,
    Tom

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://419216]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (17)
As of 2015-07-29 16:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (265 votes), past polls