Perl练习——九九乘法表

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#! perl -w
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3;
my $excel = Win32::OLE->GetActiveObject('Excel.Application') ||
Win32::OLE->new('Excel.Application', 'Quit');
my $book = $excel->Workbooks->Add;
my $sheet = $book->Worksheets(1);
foreach my $i (1..9) {
my $j = 1;
 
    while ($j <= $i) {
        my $result = $j * $i;
        my $cell_content = "$j".' X '."$i".' = '."$result";
        $sheet->Cells($i, $j)->{Value} = $cell_content;    # set value of cells
        $j ++;
    }
}
$book->SaveAs('D:\99.xls');
$book->Close;
print "成功";