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

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

  1. Arindam

    Arindam Guest

    "Hi,
    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 => "http://www.google.uk/" );

    my $parser = new Spreadsheet::parseExcel;

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

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

    if($sel->open_ok("http://www.google.co.uk/")){

    $template->AddCell(0, $row+1, $col+1, "Home Page
    :http://www.shopzilla.co.uk/"); $template->AddCell(0, $row, $col+2,
    "Pass");

    }

    else{

    $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
    1. Advertising

  2. Re: Can not locate object method "AddCell" via package

    In comp.lang.perl.misc on Sun, 30 May 2010 13:48:33 -0700 (PDT)
    Arindam <> wrote:
    > "Hi,
    > 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 Spreadsheet::WriteExcel;
    > use Spreadsheet::parseExcel;
    > use Spreadsheet::parseExcel::SaveParser;


    > my $parser = new Spreadsheet::parseExcel;
    > my $template = $parser->Parse("test_result.xls");
    >
    > $template->AddCell(0, $row+1, $col, $browser);
    >
    >
    > After running the program, I am getting the following error:-
    > Can not locate object method "AddCell" via package "Spreadsheet::
    > ParseExcel ::Workbook"


    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
    Spreadsheet::WriteExcel?


    Zebee
    Zebee Johnstone, May 30, 2010
    #2
    1. Advertising

  3. Arindam

    Jim Gibson Guest

    Re: Can not locate object method "AddCell" via package "Spreadsheet:: ParseExcel ::Workbook"

    In article
    <>,
    Arindam <> wrote:

    > "Hi,
    > 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 Spreadsheet::WriteExcel;
    > use Spreadsheet::parseExcel;
    > use Spreadsheet::parseExcel::SaveParser;


    ....

    > my $parser = new Spreadsheet::parseExcel;


    This object should be of class Spreadsheet::parseExcel::SaveParser, as
    you will be calling methods of that class below (AddCell), not of
    Spreadsheet::parseExcel.


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


    --
    Jim Gibson
    Jim Gibson, Jun 1, 2010
    #3
  4. Arindam

    Justin C Guest

    Re: Can not locate object method "AddCell" via package "Spreadsheet:: ParseExcel ::Workbook"

    On 2010-05-30, Arindam <> wrote:
    > "Hi,
    > 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:-


    [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
    guidelines.

    Justin.

    --
    Justin C, by the sea.
    Justin C, Jun 3, 2010
    #4
  5. Arindam

    Justin C Guest

    Re: Can not locate object method "AddCell" via package "Spreadsheet:: ParseExcel ::Workbook"

    In article <>, PerlTrainee wrote:
    > Okay, here is the code. Yesterday I was running the following program on Window 7 Professional 64 bit. I thought the OS was the culprit. I got this code from CSPAN website. So, I don't think there could be something wrong with the code. I ran the same code on my home computer with Window XP Professional 32 bit but got the same error.
    >
    > What I don't understand is I have specified SaveParser so why it wouldn't look for "AddCell" method there? Why it keeps looking for it in ParseExcel?
    >
    > use strict;
    > use Spreadsheet::parseExcel;
    > use Spreadsheet::parseExcel::SaveParser;
    >
    > my $parser = Spreadsheet::parseExcel->new();
    > my $workbook1 = $parser->parse('C:\readMe.xls');
    >
    > if ( !defined $workbook1 ) {
    > die $parser->error(), ".\n";
    > }
    >
    >
    > my $worksheet1 = $workbook1->worksheet('Sheet1');
    > my $parser2 = Spreadsheet::parseExcel::SaveParser->new();
    > my $workbook2 = $parser2->parse('C:\writeMe.xls');


    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):

    #!/usr/bin/perl

    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');

    $worksheet2->AddCell(20,0,'380');

    __END__

    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.

    --
    Justin C, by the sea.
    Justin C, Jul 18, 2010
    #5
  6. Re: Can not locate object method "AddCell" via package

    On 2010-07-18 10:34, Justin C <> wrote:
    > In article <>, PerlTrainee wrote:
    >> Okay, here is the code. Yesterday I was running the following
    >> program on Window 7 Professional 64 bit. I thought the OS was the
    >> culprit. I got this code from CSPAN website. So, I don't think there
    >> could be something wrong with the code. I ran the same code on my
    >> home computer with Window XP Professional 32 bit but got the same
    >> error.
    >>
    >> What I don't understand is I have specified SaveParser so why it
    >> wouldn't look for "AddCell" method there? Why it keeps looking for it
    >> in ParseExcel?
    >>
    >> use strict;
    >> use Spreadsheet::parseExcel;
    >> use Spreadsheet::parseExcel::SaveParser;
    >>
    >> my $parser = Spreadsheet::parseExcel->new();
    >> my $workbook1 = $parser->parse('C:\readMe.xls');
    >>
    >> if ( !defined $workbook1 ) {
    >> die $parser->error(), ".\n";
    >> }
    >>
    >>
    >> my $worksheet1 = $workbook1->worksheet('Sheet1');
    >> my $parser2 = Spreadsheet::parseExcel::SaveParser->new();
    >> my $workbook2 = $parser2->parse('C:\writeMe.xls');

    >
    > 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.


    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
    Spreadsheet::parseExcel::SaveParser::parse().


    > 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?


    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.

    > If I "use
    > S::pE::SP" does S::pE automatically get "used" as well?


    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.

    hp
    Peter J. Holzer, Jul 18, 2010
    #6
  7. Arindam

    Uri Guttman Guest

    Re: Can not locate object method "AddCell" via package "Spreadsheet:: ParseExcel ::Workbook"

    >>>>> "P" == PerlTrainee </> writes:

    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

    --
    Uri Guttman ------ -------- http://www.sysarch.com --
    ----- Perl Code Review , Architecture, Development, Training, Support ------
    --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
    Uri Guttman, Jul 18, 2010
    #7
  8. Re: Can not locate object method "AddCell" via package "Spreadsheet:: ParseExcel ::Workbook"

    PerlTrainee </> wrote:
    >Is that all you had to say?


    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.

    >You wrote your last email


    Email? What does email have to do with Usenet?

    >as if you were so dying to solve my problem but got disappointed when you didn't see the problem code?


    No idea what you are rambling about because you didn't provide any
    context.

    >I think the administrators should ban trolls like you. I am otta here


    What adminstrators? CLPM is -like the vast majority of Usenet- a
    non-moderated group. What adminstrators are you talking about?

    jue
    Jürgen Exner, Jul 18, 2010
    #8
  9. Arindam

    J. Gleixner Guest

    PerlTrainee wrote:
    > Okay, here is the code. Yesterday I was running the following program on Window 7 Professional 64 bit. I thought the OS was the culprit. I got this code from CSPAN website. So, I don't think there could be something wrong with the code. I ran the same code on my home computer with Window XP Professional 32 bit but got the same error.
    >
    > What I don't understand is I have specified SaveParser so why it wouldn't look for "AddCell" method there? Why it keeps looking for it in ParseExcel?
    >
    > use strict;
    > use Spreadsheet::parseExcel;
    > use Spreadsheet::parseExcel::SaveParser;
    >
    > my $parser = Spreadsheet::parseExcel->new();
    > my $workbook1 = $parser->parse('C:\readMe.xls');
    >
    > if ( !defined $workbook1 ) {
    > die $parser->error(), ".\n";
    > }
    >
    >
    > my $worksheet1 = $workbook1->worksheet('Sheet1');
    > my $parser2 = Spreadsheet::parseExcel::SaveParser->new();
    > my $workbook2 = $parser2->parse('C:\writeMe.xls');
    >


    In addition to all of the other comments, The following:

    > if (!defined $workbook2) {
    > die $parser->error(),".\n";
    > }


    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
    #9
  10. Arindam

    Jim Gibson Guest

    Re: Can not locate object method "AddCell" via package "Spreadsheet:: ParseExcel ::Workbook"

    In article <>, PerlTrainee
    </> wrote:

    > I have installed the ParseExcel v0.57 module and I read on CSPAN that this
    > module contains SaveParser. So I don't think I need to install another
    > package. I am running Perl 5.12. Is it possible that this module does not
    > support this version of Perl?


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

    Spreadsheet::parseExcel;
    Spreadsheet::parseExcel::SaveParser::Workbook;
    Spreadsheet::parseExcel::SaveParser::Worksheet;
    Spreadsheet::WriteExcel;

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

    perldoc -m Spreadsheet::parseExcel::SaveParser

    or the web page

    <http://cpansearch.perl.org/src/JMCNAMARA/Spreadsheet-ParseExcel-0.57/li
    b/Spreadsheet/ParseExcel/SaveParser.pm>

    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
    code:

    "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
    Jim Gibson, Jul 19, 2010
    #10
  11. Arindam

    Justin C Guest

    Re: Can not locate object method "AddCell" via package "Spreadsheet:: ParseExcel ::Workbook"

    In article <>, Peter J. Holzer wrote:
    > On 2010-07-18 10:34, Justin C <> wrote:


    [snip]
    >>
    >> 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.

    >
    > 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
    > Spreadsheet::parseExcel::SaveParser::parse().
    >
    >
    >> 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?

    >
    > 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.
    >
    >> If I "use
    >> S::pE::SP" does S::pE automatically get "used" as well?

    >
    > 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.


    Thank you for the explanation.

    Justin.

    --
    Justin C, by the sea.
    Justin C, Jul 19, 2010
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. GMI
    Replies:
    3
    Views:
    482
    Tad McClellan
    Jun 19, 2005
  2. Pam
    Replies:
    7
    Views:
    319
  3. Replies:
    1
    Views:
    401
    Bart Lateur
    Jun 1, 2007
  4. kj
    Replies:
    3
    Views:
    293
  5. Replies:
    7
    Views:
    151
    poornima lokhande
    Jun 8, 2014
Loading...

Share This Page