I can't vouch for how portable this solution is, since I believe that it requires certain versions of IE and Excel (and Windows, of course) However, if you want to stay entirely within ASP in order to meet your authorization requirements, try this out. If you know that your users will be using at least IE 5.01 and that they have at least Excel 2000 on their machines, then you can change $Response->{Content-Type} to 'application/vnd.ms-excel' as suggested above and simply $Response->Write the content as normal HTML tables.

IE and Excel should cooperate via OLE/ActiveX and display the content as an Excel spreadsheet within IE itself, and if the users want to save the file out, they can just select File->Save As from the IE menu, and it will default to saving as an Excel .xls file. As I mentioned, I believe that this requires minimum versions of IE and Excel, although I haven't personally tested it on other versions.

Also, for formatting purposes, you can use CSS within the various table tags via the "style" attribute. Unfortunately, using a separate CSS stylesheet (whether linked or elsewhere in the HTML) and "class" attributes doesn't seem to be reliable.

Granted, this is a narrow subset of user requirements, and you're essentially limited to non-dynamic Excel content, i.e. pure data, no formulas or other such things. However, we use a solution like this at my company to provide web-based reports to our marketing department. This allows us to use the same basic presentation code for both the HTML and Excel versions of the reports. The only modifications required to make the reports Excel-friendly are to strip out any sort of UI widgets or other unnecessary sections and then change the Content-Type.

Now, if we could just wean the marketing department off of Excel, that would be a MUCH better solution. But, alas ...

-jehuni


In reply to Re: $Session from cgi BinaryWrite from PerlScript by jehuni
in thread $Session from cgi BinaryWrite from PerlScript by guha

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.