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


In reply to How to write to a excel file while downloading in cgi perl by ghosh123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.