下面是代码,我使用while循环来写行,但只获得43行格式化的行。怎么解决这个问题?
use strict;
use Spreadsheet::WriteExcel;
my $xls=@ARGV[0];
# Create a new workbook called simple.xls and add a worksheet
my $workbook = Spreadsheet::WriteExcel->new($xls);
my $worksheet = $workbook->add_worksheet();
# The general syntax is write($row, $column, $token). Note that row and
# column are zero indexed
# Write some text
my $row=1;
$worksheet->write(0, 0, 'Hi Excel!');
while($row<100)
{
my $format = $workbook->add_format();
$format->set_bg_color('grey');
$format->set_align('center');
$worksheet->write($row, 1, "vikas veer",$format);
$row++;
}
$workbook->close();
答案 0 :(得分:1)
如果我理解正确的话。我刚刚修改了你的代码。这将为您提供100个格式化的行:
use warnings;
use strict;
use Spreadsheet::WriteExcel;
my $xls = $ARGV[0];
# Create a new workbook called simple.xls and add a worksheet
my $workbook = Spreadsheet::WriteExcel->new($xls);
my $worksheet = $workbook->add_worksheet();
# Add and define a format
my $format = $workbook->add_format();
$format->set_bg_color('grey');
$format->set_align('center');
my $col = my $row = 0;
while($row<100)
{
$worksheet->write($row, $col, "vikas veer", $format);
$row++;
}
$workbook->close();