Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Excel::Writer::XLSX 0 byte outfile

by doc1623 (Novice)
on Nov 14, 2014 at 22:15 UTC ( [id://1107260]=note: print w/replies, xml ) Need Help??


in reply to Re: Excel::Writer::XLSX 0 byte outfile
in thread Excel::Writer::XLSX 0 byte outfile

Thanks but I'm trying to do things in subroutines. I have a variable declared globally but it's instantiated and asigned only in a subroutine. I then have a seperate write subroutine. I shoudn't have to pass the worksheet, should I?
  • Comment on Re^2: Excel::Writer::XLSX 0 byte outfile

Replies are listed 'Best First'.
Re^3: Excel::Writer::XLSX 0 byte outfile
by Mr. Muskrat (Canon) on Nov 17, 2014 at 18:07 UTC

    If you want to use subroutines (as you should) then try passing parameters into your subroutines. The following code works for me. (Read: It does not produce any warnings or errors and the Excel file is properly formatted).

    #!/bin/env perl use strict; use warnings; use Excel::Writer::XLSX; my $workbook = Excel::Writer::XLSX->new( 'mytest.xlsx' ); my $worksheet = $workbook->add_worksheet( 'testsheet' ); write_me( $workbook, $worksheet ); sub write_me { my ( $workbook, $worksheet ) = @_; my $text_format = $workbook->add_format( bold => 1, italic => 1, color => 'red', size => 18, font => 'Lucida Calligraphy' ); my $result = $worksheet->write( 'A2', "Text" ); print "my result = $result\n"; $worksheet->write( 'B3', "Hello Excel", $text_format ); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-25 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found