Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Can not locate object method "AddCell" via package "Spreadsheet::

Reply
Thread Tools

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

 
 
Arindam
Guest
Posts: n/a
 
      05-30-2010
"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:arseExcel;

use Spreadsheet:arseExcel::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:arseExcel;

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

===================="
 
Reply With Quote
 
 
 
 
Zebee Johnstone
Guest
Posts: n/a
 
      05-30-2010
In comp.lang.perl.misc on Sun, 30 May 2010 13:48:33 -0700 (PDT)
Arindam <(E-Mail Removed)> 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:arseExcel;
> use Spreadsheet:arseExcel::SaveParser;


> my $parser = new Spreadsheet:arseExcel;
> 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:arseExcel
is there mention of AddCell? Or is that only in perldoc
Spreadsheet::WriteExcel?


Zebee
 
Reply With Quote
 
 
 
 
Jim Gibson
Guest
Posts: n/a
 
      06-01-2010
In article
<(E-Mail Removed)>,
Arindam <(E-Mail Removed)> 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:arseExcel;
> use Spreadsheet:arseExcel::SaveParser;


....

> my $parser = new Spreadsheet:arseExcel;


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


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


--
Jim Gibson
 
Reply With Quote
 
Justin C
Guest
Posts: n/a
 
      06-03-2010
On 2010-05-30, Arindam <(E-Mail Removed)> 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:arseExcel, 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.
 
Reply With Quote
 
Justin C
Guest
Posts: n/a
 
      07-18-2010
In article <(E-Mail Removed)>, 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:arseExcel;
> use Spreadsheet:arseExcel::SaveParser;
>
> my $parser = Spreadsheet:arseExcel->new();
> my $workbook1 = $parser->parse('C:\readMe.xls');
>
> if ( !defined $workbook1 ) {
> die $parser->error(), ".\n";
> }
>
>
> my $worksheet1 = $workbook1->worksheet('Sheet1');
> my $parser2 = Spreadsheet:arseExcel::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:arseExcel::SaveParser, the other is in
Spreadsheet:arseExcel. 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:arseExcel::SaveParser;

my $parser2 = Spreadsheet:arseExcel::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:E::SP dependant
on S:E? Could ...SaveParser be installed without S:E? If I "use
S:E::SP" does S:E 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.
 
Reply With Quote
 
Peter J. Holzer
Guest
Posts: n/a
 
      07-18-2010
On 2010-07-18 10:34, Justin C <(E-Mail Removed)> wrote:
> In article <(E-Mail Removed)>, 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:arseExcel;
>> use Spreadsheet:arseExcel::SaveParser;
>>
>> my $parser = Spreadsheet:arseExcel->new();
>> my $workbook1 = $parser->parse('C:\readMe.xls');
>>
>> if ( !defined $workbook1 ) {
>> die $parser->error(), ".\n";
>> }
>>
>>
>> my $worksheet1 = $workbook1->worksheet('Sheet1');
>> my $parser2 = Spreadsheet:arseExcel::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:arseExcel::SaveParser, the other is in
> Spreadsheet:arseExcel.


They could even both be spelled the same.

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

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


> 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:E::SP dependant
> on S:E? Could ...SaveParser be installed without S:E?


Maybe. It depends on how S:E::SP is written. The documentation of
S:E::SP should answer your questions. If it doesn't mention SE at
all, then S:E::SP is probably completely independent of S:E.

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


No. S:E::SP may use S:E, but if it does, any symbols exported by
S:E are only imported into S:E::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
 
Reply With Quote
 
Uri Guttman
Guest
Posts: n/a
 
      07-18-2010
>>>>> "P" == PerlTrainee <(E-Mail Removed)/> 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.velocityreviews.com/forums/(E-Mail Removed) -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      07-18-2010
PerlTrainee <(E-Mail Removed)/> 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
 
Reply With Quote
 
J. Gleixner
Guest
Posts: n/a
 
      07-19-2010
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:arseExcel;
> use Spreadsheet:arseExcel::SaveParser;
>
> my $parser = Spreadsheet:arseExcel->new();
> my $workbook1 = $parser->parse('C:\readMe.xls');
>
> if ( !defined $workbook1 ) {
> die $parser->error(), ".\n";
> }
>
>
> my $worksheet1 = $workbook1->worksheet('Sheet1');
> my $parser2 = Spreadsheet:arseExcel::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:arseExcel
class. More than likely, you would want to call error from
the Spreadsheet:arseExcel::SaveParser class.

die $parser2->error;

Also, note the side effect when you add a newline to die's output.


 
Reply With Quote
 
Jim Gibson
Guest
Posts: n/a
 
      07-19-2010
In article <(E-Mail Removed)>, PerlTrainee
<(E-Mail Removed)/> 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:arseExcel::SaveParser (SPESP) module depends upon
these modules:

Spreadsheet:arseExcel;
Spreadsheet:arseExcel::SaveParser::Workbook;
Spreadsheet:arseExcel::SaveParser::Worksheet;
Spreadsheet::WriteExcel;

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

perldoc -m Spreadsheet:arseExcel::SaveParser

or the web page

<http://cpansearch.perl.org/src/JMCNA...eExcel-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:arseExcel and SpreadSheet::WriteExcel modules to copy an
existing spreadsheet and updates it contents.

--
Jim Gibson
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSUB detecting if it was called via Package->method() or Package::method()? Chris Perl Misc 7 11-18-2010 03:33 AM
"Can't locate object method "PV" via package "B::SPECIAL"" kj Perl Misc 3 10-20-2007 05:02 PM
Can't locate object method "host" via package "URI::_foreign" vkinger@hotmail.com Perl Misc 1 06-01-2007 05:35 PM
Can't locate boject methoid Cells via package Sspreadsheet::WriteExcel::Worksheet Pam Perl Misc 7 09-22-2006 11:02 PM
Can't locate object method "first" via package "attempt" (perhaps you forgot to load "attempt"?) at .... GMI Perl Misc 3 06-19-2005 10:44 PM



Advertisments