N
ngoc
Hi
This code does not work. It only creates test.xls, but write nothing in
it.I don't know why. Please help me. Thanks a lot.
test.pl
#/usr/bin/perl
use Test;
new Test('/home/my/test.xls');
Test.pm
package Test;
use strict;
use Spreadsheet::WriteExcel;
use Spreadsheet::WriteExcel::Big;
use vars qw {$workbook $sheet1 $title_format};
sub new {
my $self = {};
my ($class,$file_name) = @_;
bless $self, "Test";
$workbook = Spreadsheet::WriteExcel::Big -> new ($file_name);
&sheet;
&format;
&title ('test_sid', 'test_project');
return $self;
}
sub sheet {
$sheet1 = $workbook -> add_worksheet("test");
#Set the width of the first column in Sheet1
$sheet1 -> set_column('A:A', 30);
$sheet1 -> set_column('B:M', 20);
#Set Sheet1 as the active worksheet
$sheet1 -> activate();
}
sub format {
# title format
$title_format = $workbook -> add_format();
$title_format -> set_bold ();
$title_format -> set_size (16);
$title_format -> set_color ('blue');
$title_format -> set_align ('left');
}
sub title {
my $sid_name = shift;
my $project_name = shift;
$sheet1 -> write(0, 0, $sid_name, $title_format);
$sheet1 -> write(0, 1, $project_name, $title_format);
$sheet1 -> write(1, 0, "TEST1", $title_format);
$sheet1 -> write(2, 0, "TEST2", $title_format);
}
1;
This code does not work. It only creates test.xls, but write nothing in
it.I don't know why. Please help me. Thanks a lot.
test.pl
#/usr/bin/perl
use Test;
new Test('/home/my/test.xls');
Test.pm
package Test;
use strict;
use Spreadsheet::WriteExcel;
use Spreadsheet::WriteExcel::Big;
use vars qw {$workbook $sheet1 $title_format};
sub new {
my $self = {};
my ($class,$file_name) = @_;
bless $self, "Test";
$workbook = Spreadsheet::WriteExcel::Big -> new ($file_name);
&sheet;
&format;
&title ('test_sid', 'test_project');
return $self;
}
sub sheet {
$sheet1 = $workbook -> add_worksheet("test");
#Set the width of the first column in Sheet1
$sheet1 -> set_column('A:A', 30);
$sheet1 -> set_column('B:M', 20);
#Set Sheet1 as the active worksheet
$sheet1 -> activate();
}
sub format {
# title format
$title_format = $workbook -> add_format();
$title_format -> set_bold ();
$title_format -> set_size (16);
$title_format -> set_color ('blue');
$title_format -> set_align ('left');
}
sub title {
my $sid_name = shift;
my $project_name = shift;
$sheet1 -> write(0, 0, $sid_name, $title_format);
$sheet1 -> write(0, 1, $project_name, $title_format);
$sheet1 -> write(1, 0, "TEST1", $title_format);
$sheet1 -> write(2, 0, "TEST2", $title_format);
}
1;