ghosh123 has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I am working on extracting some information from a webpage and dumping them into a excel file. The webpage from which I am extracting the report has link on it as 'Create report'. Upon clicking that link it goes to a script in the server and does the following things :
1. Creates the Excel using Spreadsheet::WriteExcel
2. Extracts the page content using LWP::UserAgent, HTML::TableExtract qw(tree)
3. Writes to the excel and closes it .
4. Lets the user download it.
Now the question is, how can I write something to that generated excel file in time of downloading it. Say for example I want to write some heading and title at the begining of the excel file while downloading.
All the above 4 functionalities are working fine. For your ease of understanding I am just putting the last part of the code below :
## please assume that extracting the page content and ## writing to the excel is already done before this ## following code : $workbook->close; open(FILE, "<$filename") || die "Unable to download file \n"; my @fileholder; @fileholder = <FILE>; close (FILE); unlink $filename; print "Content-Type:application/x-download\n"; print "Content Disposition:attachment;filename=report.xls\n\n"; print @fileholder;
Thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to write to a excel file while downloading in cgi perl
by Corion (Patriarch) on Aug 02, 2013 at 07:06 UTC | |
Re: How to write to a excel file while downloading in cgi perl
by glasswalk3r (Friar) on Aug 02, 2013 at 21:22 UTC |