Problem with Perl script for RT

Sorry for disturbing you but I’m completely new to object-oriented Perl,
and I’ve got a problem that completely not able to cope with:
What I wanna do is put some data about tickets into Excel file (sth like
a report done with Search in RT).
I’m downloaded Spreadsheet::WriteExcel library and tried to make sth
using it. I managed to mage a file starting a perl script from command
line so the library is working. But I really can’t make it working with
my RT.
Can anybody show me how to run this in RT using for instance a very
simple code:

#!/usr/bin/perl -w

use strict;
use Spreadsheet::WriteExcel;

Create a new Excel workbook called perl.xls

my $workbook = Spreadsheet::WriteExcel->new(“perl.xls”);
my $worksheet = $workbook->addworksheet();

Write some text and some numbers

Row and column are zero indexed

$worksheet->write(0, 0, “The Perl Journal”);
$worksheet->write(1, 0, “One” );
$worksheet->write(2, 0, “Two” );
$worksheet->write(3, 0, 3 );
$worksheet->write(4, 0, 4.0000001 );

How to make it working run from ‘/opt/rt3/share/html/Search/’ directory
in my RT ?

When I try to start it just putting ‘%’ before every line I get:

System error

error:
Can’t call method “addworksheet” on an undefined value at
/opt/rt3/share/html/Search/ListingExcel2Report.html line 5.

context:

1:
%use strict;

2:
%use Spreadsheet::WriteExcel;

3:
%# Create a new Excel workbook called perl.xls

4:
%my $workbook = Spreadsheet::WriteExcel->new(“perl.xls”);

5:
%my $worksheet = $workbook->addworksheet();

6:
%# Write some text and some numbers

7:
%# Row and column are zero indexed

8:
%$worksheet->write(0, 0, “The Perl Journal”);

9:
%$worksheet->write(1, 0, “One” );

Lost of thanks in advance - you’ll give me a great birthday present :wink:
Greets
Krzysztof Opała
Comarch Kraków S.A.
Poland

Krzysztof Opała wrote:

Sorry for disturbing you but I’m completely new to object-oriented Perl,
and I’ve got a problem that completely not able to cope with:

What I wanna do is put some data about tickets into Excel file (sth like
a report done with Search in RT).

I’m downloaded Spreadsheet::WriteExcel library and tried to make sth
using it. I managed to mage a file starting a perl script from command
line so the library is working. But I really can’t make it working with
my RT.

Can anybody show me how to run this in RT using for instance a very
simple code:

Comments below.

#!/usr/bin/perl -w

use strict;

use Spreadsheet::WriteExcel;

Create a new Excel workbook called perl.xls

my $workbook = Spreadsheet::WriteExcel->new(“perl.xls”);
I think that constructor return undef because it can’t create perl.xls
in CWD. You should use some base dir for *.xls files. Also you can’t use
one file name.

my $worksheet = $workbook->addworksheet();

Write some text and some numbers

Row and column are zero indexed

$worksheet->write(0, 0, “The Perl Journal”);

[snip]

Make sure to add debugging everywhere. Things like really help

my $workbook = Spreadsheet::WriteExcel->new(“perl.xls”) or die “couldn
not create workbook: $!\n”;

Ruslan U. Zakirov wrote: