After toying around with the code for this module for a bit, I've fixed the problem, hopefully without introducing any new bugs (my understanding of the module is not very complete). This bug is caused by the "class data" at the beginning of Format.pm and Worksheet.pm. The data is actually per-workbook data, but the author of the module mistakenly stored it into class variables, thus applying it to the set of all worksheets and formats. I've made this mistake so many times myself, it was quite easy to recognize :) Anyway, I've whipped up a quick patch to get things working. One caveat with the patch though, is that you have to explicitly close() your workbooks, because the order in which objects get DESTROY'd is random.
diff -r c:\perl\site\lib\Spreadsheet/Format.pm C:\Perl\CPAN\Spreadshee +t-WriteExcel-0.22/Format.pm 32,33c32,33 < # my $xf_index = 15; < # my $font_index = 4; --- > my $xf_index = 15; > my $font_index = 4; 47,49c47 < _workbook => $_[1], < _xf_index => $_[1]->{_xf_index}, #MEOW < _font_index => $_[1]->{_font_index}, #MEOW --- > _xf_index => $xf_index, 50a49 > _font_index => $font_index, 89,90c88,89 < $self->{_workbook}{_xf_index}++; < $self->{_workbook}{_font_index}++; --- > $xf_index++; > $font_index++; diff -r c:\perl\site\lib\Spreadsheet/Workbook.pm C:\Perl\CPAN\Spreadsh +eet-WriteExcel-0.22/Workbook.pm 38,39d37 < bless $self, $class; < 49,52c47,48 < $self->{_xf_index} = 15; < $self->{_font_index} = 4; < $self->{_tmp_worksheet} = Spreadsheet::Worksheet->new('', 0, 0, + $self); < $self->{_tmp_format} = Spreadsheet::Format->new($self); --- > $self->{_tmp_worksheet} = Spreadsheet::Worksheet->new('', 0, 0) +; > $self->{_tmp_format} = Spreadsheet::Format->new(); 55a52 > bless $self, $class; 133d129 < $self, #MEOW 152c148 < my $format = Spreadsheet::Format->new($self); --- > my $format = Spreadsheet::Format->new(); diff -r c:\perl\site\lib\Spreadsheet/Worksheet.pm C:\Perl\CPAN\Spreads +heet-WriteExcel-0.22/Worksheet.pm 32,33c32,33 < #MEOW my $active_sheet = 0; < #MEOW my $first_sheet = 0; --- > my $active_sheet = 0; > my $first_sheet = 0; 53d52 < $self->{_workbook} = $_[3]; #MEOW 200c199 < $self->{_workbook}{_active_sheet} = $self->{_index}; #MEOW --- > $active_sheet = $self->{_index}; 212,214c211 < my $self = shift; #MEOW < < $self->{_workbook}{_active_sheet}; #MEOW --- > return $active_sheet; 229c226 < $self->{_workbook}{_first_sheet} = $self->{_index}; #MEOW --- > $first_sheet = $self->{_index}; 241,243c238 < my $self = shift; < < $self->{_workbook}{_first_sheet}; #MEOW --- > return $first_sheet; 341c336 < if ($self->{_workbook}{_active_sheet} == $self->{_index}) { --- > if ($active_sheet == $self->{_index}) {

In reply to Re: Spreadsheet::WriteExcel - using formats with multiple books (Fixed) by MeowChow
in thread Spreadsheet::WriteExcel - using formats with multiple books by nop

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.