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 :
open(FILE, "<$filename") || die "Unable to download file \n";
@fileholder = <FILE>; close (FILE);
print "Content Disposition:attachment;filename=report.xls\n\n";