Can not locate object method "AddCell" via package "Spreadsheet::

Discussion in 'Perl Misc' started by Arindam, May 30, 2010.

  1. Arindam

    Arindam Guest

    I am trying to to learn PERL, I am using it for an Automation Tool,
    Selenium RC. My target is to open google. If the operation is
    successful, I will open an existing excel sheet and write PASS, if it
    fails, It will write Fail. I have installed the required library. The
    code is as follows:-

    use strict;

    use warnings;

    use Time::HiRes qw(sleep);

    use Test::WWW::Selenium;

    use Test::More "no_plan";

    use Test::Exception;

    use Spreadsheet::WriteExcel;

    use Spreadsheet::parseExcel;

    use Spreadsheet::parseExcel::SaveParser;

    print "\n\n **Enter You Browser Choice :: ";

    my $browser = <STDIN>;

    my $row;

    my $col;

    my $count;

    my $sheet;

    $row = 0;

    $col = 0;

    $sheet = 0;

    $count = 1;

    my $sel = Test::WWW:: Selenium->new( host => "localhost",
    port => 4444,
    browser => "*$browser",
    browser_url => "" );

    my $parser = new Spreadsheet::parseExcel;

    my $template = $parser->Parse("test_result.xls");

    $template->AddCell(0, $row+1, $col, $browser);


    $template->AddCell(0, $row+1, $col+1, "Home Page
    :"); $template->AddCell(0, $row, $col+2,



    $template->AddCell(0, $row+1, $col+3, "Fail");

    After running the program, I am getting the following error:-
    Can not locate object method "AddCell" via package "Spreadsheet::
    ParseExcel ::Workbook"

    I would be grateful, if anyone could give me some guidance to
    resolve the problem.

    Thanking You in Anticipation,
    Arindam Pattanayak

    Arindam, May 30, 2010
    1. Advertisements

  2. In comp.lang.perl.misc on Sun, 30 May 2010 13:48:33 -0700 (PDT)
    I know nothing about those modules, but it looks to me like one called
    "ParseExcel" is reading not writing.

    If you want to write, should you be creating an object with WriteExcel
    not ParseExcel?

    and if you do
    perldoc Spreadsheet::parseExcel
    is there mention of AddCell? Or is that only in perldoc

    Zebee Johnstone, May 30, 2010
    1. Advertisements

  3. Arindam

    Jim Gibson Guest

    This object should be of class Spreadsheet::parseExcel::SaveParser, as
    you will be calling methods of that class below (AddCell), not of
    Jim Gibson, Jun 1, 2010
  4. Arindam

    Justin C Guest

    [snipped a complete mess of irrelevance]

    Please post a *minimal* example of the problem - refer to the posting
    guidlines which are posted to the group very frequently.

    Your problem is that your template object comes from
    Spreadsheet::parseExcel, this module doesn't know how to create
    anything, only read existing Excel files. You need to take information
    obtained from your template and create a new Excel object using those
    settings with Spreadsheet::WriteExcel. You then call the AddCell method
    with this object.

    For better answers to your questions please post according to the

    Justin C, Jun 3, 2010
  5. Arindam

    Justin C Guest

    I got your code to work by changing the above line to:
    my $workbook2 = $parser2->Parse('C:\writeMe.xls');
    (note the upper-case 'P' ^ here)

    I don't pretend to be an expert, but I've done some investigation and I
    find that there are two methods defined: Parse, and parse, but they are
    not the same! The one with the upper-case P is in
    Spreadsheet::parseExcel::SaveParser, the other is in
    Spreadsheet::parseExcel. Even if I strip your code down to it's barest
    minimum which still shows the error (which is what you should have done,
    and you may have found this for yourself):


    use warnings;
    use strict;
    use Spreadsheet::parseExcel::SaveParser;

    my $parser2 = Spreadsheet::parseExcel::SaveParser->new();
    my $workbook2 = $parser2->parse('excel/xmas96.xls');

    my $worksheet2 = $workbook2->worksheet('Sheet1');



    I use modules in a lot of what I code, but when they are like this I
    don't really understand what is going on. I mean, is S::pE::SP dependant
    on S::pE? Could ...SaveParser be installed without S::pE? If I "use
    S::pE::SP" does S::pE automatically get "used" as well? Or does
    specifying ...SaveParser work like "use CGI qw/standard/" and only pull
    in the methods specified?

    I hope the OP gets something useful out of this, because all it's done
    is make me more confused.

    Justin C, Jul 18, 2010
  6. They could even both be spelled the same.

    $parser is an object of the class 'Spreadsheet::parseExcel', so
    $parser->parse() calls Spreadsheet::parseExcel::parse.

    $parser2 is an object of the class
    'Spreadsheet::parseExcel::SaveParser', so $parser2->Parse() calls

    Maybe. It depends on how S::pE::SP is written. The documentation of
    S::pE::SP should answer your questions. If it doesn't mention S:pE at
    all, then S::pE::SP is probably completely independent of S::pE.
    No. S::pE::SP may use S::pE, but if it does, any symbols exported by
    S::pE are only imported into S::pE::SP, not into your current package.

    Note that in object-oriented Perl, symbols are not usually exported:
    Instead the full class name is used for class methods like new, and
    instance methods are referenced via the object anyway. So if you use
    class A and class A uses class B, you can use class B just as if you had
    used it yourself.

    Peter J. Holzer, Jul 18, 2010
  7. Arindam

    Uri Guttman Guest

    P> Is that all you had to say? You wrote your last email as if you
    P> were so dying to solve my problem but got disappointed when you
    P> didn't see the problem code? I think the administrators should ban
    P> trolls like you. I am otta here

    who are you refering to? there is no quote or attribution. for a
    supposed perl trainee you aren't doing a good job listening to what
    people tell you.

    Uri Guttman, Jul 18, 2010
  8. What did who say? It is a time-honored proven Usenet custom to quote
    sufficient context such that any posting makes sense on its own.
    Email? What does email have to do with Usenet?
    No idea what you are rambling about because you didn't provide any
    What adminstrators? CLPM is -like the vast majority of Usenet- a
    non-moderated group. What adminstrators are you talking about?

    Jürgen Exner, Jul 18, 2010
  9. Arindam

    J. Gleixner Guest

    In addition to all of the other comments, The following:
    will call the error method from the Spreadsheet::parseExcel
    class. More than likely, you would want to call error from
    the Spreadsheet::parseExcel::SaveParser class.

    die $parser2->error;

    Also, note the side effect when you add a newline to die's output.
    J. Gleixner, Jul 19, 2010
  10. Arindam

    Jim Gibson Guest

    The Spreadsheet::parseExcel::SaveParser (SPESP) module depends upon
    these modules:


    You can see this from the source, which can be displayed using the

    perldoc -m Spreadsheet::parseExcel::SaveParser

    or the web page


    It is possible you need to have compatible versions of all five modules
    for the modules to work.

    Note that SPESP was moribund for many years and has been taken over by
    a new maintainer, who has placed the following warning in the source

    "Please note that this module is currently (versions 0.50-0.60)
    undergoing a major restructuring and rewriting."

    Thus, problems can be anticipated.

    If you can't wait for these problems to be fixed, and if your
    requirements are modest, you may be able to use the
    Spreadsheet::parseExcel and SpreadSheet::WriteExcel modules to copy an
    existing spreadsheet and updates it contents.
    Jim Gibson, Jul 19, 2010
  11. Arindam

    Justin C Guest

    Thank you for the explanation.

    Justin C, Jul 19, 2010
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.