Hi Raj. This is possibly Off-Topic, but here goes!

I was successfully able to serve up dynamic Excel files via the Apache Web Server to a web browser about a year ago. I went digging up through my file system and found this snippet. This is meant for a *NIX box, by the way - this might cause a problem when trying to write the temporary file on Win32 boxes.

use strict; use CGI qw(header); use POSIX; use Spreadsheet::WriteExcel; my $tmp_file = tmpnam(); { my $workbook = Spreadsheet::WriteExcel->new($tmp_file) or die; my $worksheet = $workbook->addworksheet() or die; my $format = $workbook->addformat() or die; $format->set_bold(); $format->set_color('red'); $format->set_align('center'); $worksheet->write(0, 0, "Hi Excel!"); $worksheet->write(1, 0, 1.2345); $worksheet->write(2, 0, "Hi Excel!", $format); } open(FH,$tmp_file) or die; print header(-type=>'application/vnd.ms-excel'); print while <FH>; unlink $tmp_file;
If the user's Win32 box has Excel installed, Internet Explorer will use OLE to display the spreadsheet right in the browser. A catch is that the .cgi extension will confuse non-savvy users who don't know to save the file with a .xls extension instead. But ...

A really nice feature of the Apache web server is being able to specify your own extensions for CGI scripts. By adding this line to your <Directory> directive:

AddHandler cgi-script .xls
Now the Excel file can be saved 'as-is' without having to worry about getting the extension right.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: Error invoking Excel through cgi by jeffa
in thread Error invoking Excel through cgi by Anonymous Monk

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.