From: Jeff on
Hi-

Im trying to use this the Spreadsheet::ParseExcel module and
having difficulty getting started. When I use the examples Ive
seen I get the following error:

Attempt to bless into a reference at /usr/local/lib/perl5/site_perl/
5.10.0/Spreadsheet/ParseExcel.pm line 178.

I havent coded much since I was trying to figure out how to use it,
my code is just:

#!/usr/bin/perl -w

use Spreadsheet::ParseExcel;

my $parse = new Spreadsheet::ParseExcel->new() || die "ERROR creating
new object";
exit 0

I just downloaded the module today so it should be the latest.
Im running perl 5.10.0 on Linux fedora core.

Any suggestions as to what to check?
Thanks


From: Uri Guttman on
>>>>> "J" == Jeff <jeep(a)rahul.net> writes:

J> my $parse = new Spreadsheet::ParseExcel->new() || die "ERROR creating

why are you calling new() twice there? pick on (the ->new() is better).

uri

--
Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
From: Justin C on
In article <3b575382-284e-448e-a8fb-050bcde54355(a)11g2000prw.googlegroups.com>, Jeff wrote:
> Hi-
>
> Im trying to use this the Spreadsheet::ParseExcel module and
> having difficulty getting started. When I use the examples Ive
> seen I get the following error:
>
> Attempt to bless into a reference at /usr/local/lib/perl5/site_perl/
> 5.10.0/Spreadsheet/ParseExcel.pm line 178.
>
> I havent coded much since I was trying to figure out how to use it,
> my code is just:
>
> #!/usr/bin/perl -w
>
> use Spreadsheet::ParseExcel;
>
> my $parse = new Spreadsheet::ParseExcel->new() || die "ERROR creating
> new object";
> exit 0
>
> I just downloaded the module today so it should be the latest.
> Im running perl 5.10.0 on Linux fedora core.
>
> Any suggestions as to what to check?
> Thanks

You've got too many 'new's on the "my $parse" line. Instead try:

my $parse = Spreadsheet::ParseExcel->new();

I think the "or die" bit is redundant too, if it doesn't succeed then
there will be an error anyway. The module documentation has an
alternative based on the fact that you're also going to want an Excel
workbook to parse:

my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse('Book1.xls');

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

I don't know what documentation you are reading, but take a look at
what's here:
<URL:http://search.cpan.org/~jmcnamara/Spreadsheet-ParseExcel-0.57/lib/Spreadsheet/ParseExcel.pm>.

Justin.

--
Justin C, by the sea.
From: Steve M on
On 5/2/2010 10:06 AM, Jeff wrote:
> Hi-
>
> Im trying to use this the Spreadsheet::ParseExcel module and
> having difficulty getting started. When I use the examples Ive
> seen I get the following error:
>
> Attempt to bless into a reference at /usr/local/lib/perl5/site_perl/
> 5.10.0/Spreadsheet/ParseExcel.pm line 178.
>
> I havent coded much since I was trying to figure out how to use it,
> my code is just:
>
> #!/usr/bin/perl -w
>
> use Spreadsheet::ParseExcel;
>
> my $parse = new Spreadsheet::ParseExcel->new() || die "ERROR creating
^^^^ ???

> new object";
> exit 0
>
> I just downloaded the module today so it should be the latest.
> Im running perl 5.10.0 on Linux fedora core.
>
> Any suggestions as to what to check?
> Thanks
>
>

use Spreadsheet::ParseExcel;

my $file = '/path/to/file.xls';

my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->Parse($file);
my $worksheet = $workbook->Worksheet(0); # assume first sheet

hth,

\s
--
"There is no use in your walking five miles to fish when you can depend
on being just as unsuccessful near home." M. Twain
From: C.DeRykus on
On May 2, 10:53 am, Justin C <justin.1...(a)purestblue.com> wrote:
> In article <3b575382-284e-448e-a8fb-050bcde54...(a)11g2000prw.googlegroups.com>, Jeff wrote:
> > Hi-
>
> > Im trying to use this the Spreadsheet::ParseExcel module and
> > having difficulty getting started.  When I use the examples Ive
> > seen I get the following error:
>
> > Attempt to bless into a reference at /usr/local/lib/perl5/site_perl/
> > 5.10.0/Spreadsheet/ParseExcel.pm line 178.

>
> > ...
>
> > my $parse = new Spreadsheet::ParseExcel->new() || die "ERROR creating
> > new object";
> > exit 0


The additional 'new' results in

my $parse = Spreadsheet::ParseExcel->new->new

which causes perl to die:

perl -MSpreadsheet::ParseExcel -e '$p=Spreadsheet::ParseExcel
->new->new'
Attempt to bless into a reference at -e line 1.

> ...
>
> my $parse = Spreadsheet::ParseExcel->new();
>
> I think the "or die" bit is redundant too, if it doesn't succeed
> ...

Or you may want to wrap the call in an eval {} for more
control...

my $parse = eval { Spreadsheet::ParseExcel->new(); };
die "error: ... $@" if $@;

--
Charles DeRykus