![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Downloading file from internet | chetanpc | Shell Programming and Scripting | 4 | 03-25-2008 04:36 PM |
| Downloading a csv file automatically | figaro | Shell Programming and Scripting | 2 | 03-19-2008 05:36 PM |
| Script to generate text file from excel file | isingh786 | UNIX for Dummies Questions & Answers | 1 | 01-24-2008 10:32 AM |
| How to attach an excel file/ dat file thru unix mails | diwakar82 | Shell Programming and Scripting | 1 | 01-06-2006 11:23 AM |
| how can i read an excel file using C? | DebianJ | High Level Programming | 6 | 07-01-2005 02:19 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Downloading Excel File
Hello All,
Currently working with CGI scripts in perl which involves a) uploading b) processing c) downloading the file back to the user uploading and processing quite trivial and they are done Third part is kind of being tricky. Excel file in binary format is getting displayed in the html page itself and not popping up a download window for downloading file to the client's machine Code snippet Code:
my @fileholder; open(EXCLFILE, "<", $file_path) or die "Unable to download file $file_path\n"; binmode EXCLFILE; @fileholder = <EXCLFILE>; close (EXCLFILE); print "Content-Type:application/vnd.ms-excel\n"; print "Content-Disposition:attachment;filename=$file_path\n\n"; print @fileholder; Thanks ![]() Last edited by matrixmadhan; 01-15-2008 at 12:43 PM.. |
|
|||||
|
put "application/octet-stream" instead of "vnd.ms-excel" , it should work. Else, look at these thread, it may help.
|
|
||||
|
This is completely running over my head.
I did went through the link provided in perlmonks and tried it, but its refusing to work ![]() Please find the snippet below Code:
my $cgi = new CGI;
open(DLFILE, "<$abs_path") || die "Unable to download file $abs_path\n";
print $cgi->header(
'-type' => "application/octet-stream; name=$filename",
'-Content-Disposition' => "attachment; filename=$abs_path",
'-Content-Transfer-Encoding' => "binary");
binmode DLFILE;
print while(<DLFILE>);
close (DLFILE);
Code:
$abs_path = "/home/matrix/file.xls"; $filename = "file.xls"; and all the binary contents of the excel file is displayed as such in the html page. Any pointers again, much appreciated ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|