0
use strict;
use lib qw(./lib);
use Spreadsheet::WriteExcel;
use Math::Random qw(:all);


    $worksheet->write(0, 0, "Zahl", $format); 
    $worksheet->write(0, 1, "Vorkommt",$bold);

    my @rand_arr = map int,random_normal(10,5,5);

    my ($temp,$count) = ("@rand_arr", 0);   
    ($count = $temp =~ s/($_)//g) and printf "%2d:%s vor.\n", $_,$count for @rand_arr;

    $worksheet->write(1, 0, "$_");
    $worksheet->write(1, 1, "$count");


    $workbook->close();

    print "\n";

如果您这样做,您将在终端中获得良好的输出,但我想做的是,在 Excel 中获得相同的输出,我认为我的问题就在这里

$worksheet->write(1, 0, "$_");
$worksheet->write(1, 1, "$count"); 

我不知道如何让 excel 单独使用 $ROW++ ..

4

1 回答 1

1

我不确定您对终端代码的输出在做什么 - 它看起来很奇怪。

也许你只是想要:

for my $row (0..$#rand_arr) {
    $worksheet->write($row+1, 0, $row);
    $worksheet->write($row+1, 1, $rand_arr[$row]);
}
于 2013-11-10T23:23:46.180 回答