Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^4: capturing STDOUT

by Anonymous Monk
on Oct 09, 2012 at 19:58 UTC ( #998062=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: capturing STDOUT
in thread capturing STDOUT

My below is script not generating STDOUT in browser. I followed the instructions u have given bt didn't work.. Can someone help on this..

#!/appl/CW_NETCOOL/PERL/bin/perl use strict; use Spreadsheet::WriteExcel; use CGI qw(:standard); # Set the filename and send the content type my $filename ="cgitest.xls"; print "Content-type: application/\n"; #print "Content-Disposition: attachment; filename=$filename\n\n"; # Create a new workbook and add a worksheet. The special Perl filehand +le will # redirect the output to STDOUT # binmode(STDOUT); my $workbook = Spreadsheet::WriteExcel->new(\*STDOUT); my $worksheet = $workbook->addworksheet(); # Set the column width for column 1 $worksheet->set_column(0, 0, 20); # Create a format my $format = $workbook->addformat(); $format->set_bold(); $format->set_size(15); $format->set_color('blue'); # Write to the workbook $worksheet->write(0, 0, "Hi Excel!", $format); $workbook->close;

Replies are listed 'Best First'.
Re^5: capturing STDOUT
by tobyink (Abbot) on Oct 09, 2012 at 20:31 UTC

    Here's your problem:

    print "Content-type: application/\n"; #print "Content-Disposition: attachment; filename=$filename\n\n";

    HTTP headers need to end in a double line break. Your Content-Type header has only one. Your Content-Disposition header would do the trick, but it's commented out.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      I followed your suggestion but the file is getting download with prompt.

      How do I Print Xcel sheet in the browser

      Here My requirement is "User should able to copy the columns content from browser ouput". When I use html , we are able to copy the rows and not columns

      Why I'm preferring Xls , bcoz user should able to download the files as xls or csv with 'Sava as' Option

      Please help me on this

        You could try setting Content-Disposition: inline, but be aware that the Content-Disposition header is just advisory. The browser is free to do what it likes with the file: open it in an external program, save it to disk, or stir some eggs and cream into it and make it into a lovely soufflé. The inline disposition indicates that you'd like it to open within the browser window, but I don't think very many browsers are capable of doing that.

        Personally I'd format it as an HTML table and use a little Javascript trickery to allow people to select columns and copy them to the clipboard.

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998062]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2017-09-23 06:14 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (271 votes). Check out past polls.