Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: $Session from cgi BinaryWrite from PerlScript

by trantor (Chaplain)
on Oct 05, 2001 at 16:09 UTC ( [id://116966]=note: print w/replies, xml ) Need Help??


in reply to $Session from cgi BinaryWrite from PerlScript

I've done this in the past using Apache::ASP.

Choice 1 is highly non-portable, due to the vairous ways of storing session data.

I would recommend choice 2, there's no need to use $Response->BinaryWrite, but you must set the correct Content-type. Thus you could say:

$Response->{ContentType} = 'application/vnd.ms-excel'; # Generate your sheet and store it in $sheet print $sheet; # Or $Response->Write($sheet);

-- TMTOWTDI

Replies are listed 'Best First'.
Re: $Session from cgi BinaryWrite from PerlScript
by jehuni (Pilgrim) on Oct 07, 2001 at 19:00 UTC

    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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://116966]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2024-04-18 16:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found