Hello MissPerl,

Well I just read your question and I remembered that maybe 5 - 6 years ago that another monk asked the same question writing after parsing.

Take a look on the question but I spend some time and I created a script that it was merging excel files into one here is the link Re^2: writing after parsin.

Let me know if it works, alternatively I can spend some time and debug it.

Update: I tested your code and you have many errors.

Let's fix them:

use warning; # needs to be use warnings; my $path = '/abc'; my $te = "$abc/texas"; # I assume you mean $path instead of $abc? my $mi = "$abc/michigan"; I assume you mean $path instead of $abc? my $ha = "$abc/hawaii"; I assume you mean $path instead of $abc? my $fl = "$abc/florida"; I assume you mean $path instead of $abc? my $ke = "$abc/kentucky"; I assume you mean $path instead of $abc? my $filename = "path/one.xls"; # needs to be my $filename = "$path/one +.xls"; my $excl = Spreadsheet::WriteExcel->new($filename) or die "Cannot create new Excel file: $!" unless defined $excl; # thi +s will not work my $workbook = Spreadsheet::WriteExcel->new('protected.xls'); # from +module documentation (notice the ";" here) die "Problems creating new Excel file: $!" unless defined $workbook; # + from module documentation # add the following after the part my $book = $parser->parse($source); for my $source ( '$te/te.xls', '$mi/mi.xls', # all files need to be de +fined with double quotes (e.g. "$te/te.xls") '$ha/ha.xls', '$fl/fl.xls', # with single quotes will not wor +k '$ke/ke.xls' ){ my $book = $parser->parse($source); if ( !defined $book ) { die $parser->error(), ".\n"; }

Update2: I also noticed:

if ($source =~ /1/) { $file = $excl->add_worksheet('Texas'); }

This will never work, you are invoking a method from Spreadsheet::WriteExcel/add_worksheet($sheetname, $utf_16_be) but the object that you are using is from Spreadsheet::ParseExcel/new(). Change object use the one that is for writing.

After fixing all the errors give it another try.

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!

In reply to Re: Spreadsheet::WriteExcel; combining xls into one by thanos1983
in thread Spreadsheet::WriteExcel; combining xls into one by MissPerl

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.