http://www.perlmonks.org?node_id=1056236


in reply to Re: Not able to create worksheets inside a subroutine
in thread Not able to create worksheets inside a subroutine

Thanks...i found out what the problem is...i was not declaring wrokbook as type my(local).Can you try running you code after removing my it woudnt work..i dont understand why
  • Comment on Re^2: Not able to create worksheets inside a subroutine

Replies are listed 'Best First'.
Re^3: Not able to create worksheets inside a subroutine
by hdb (Monsignor) on Sep 29, 2013 at 16:04 UTC

    No, removing my is not the way to go at all. Always use strict;, clear away all errors and then see what happens.

      I cant declare workbook as my as i need to use it in other subs too

        Then, at least, declare it as a globel variable, ie outside of all subs. Or, better, pass it as a parameter into the subs, that need it.

Re^3: Not able to create worksheets inside a subroutine
by ig (Vicar) on Sep 30, 2013 at 07:15 UTC

    Spreadsheet::WriteExcel tries to close your workbook automatically but sometimes has problems "If the new(), add_worksheet() or add_format() methods are called in subroutines." You can read the section on the close() method for more detail on limitations of automatic closing.