你的分享就是我们的动力 ---﹥

Perl 使用 OLE 自动化来控制 Excel

时间:2013-05-30 00:07来源:www.chengxuyuans.com 点击:

Perl代码

#!/usr/bin/perl -w

use Win32::OLE;

$class = 'Excel.Application';

$app = Win32::OLE->new( $class ) or die "Cannot connect to Excel, $!";


# Make application visible.
$app->{'Visible'} = 1;

# Create a new workbook.
$app->Workbooks->Add();


# Set values in a "range".
$app->Range("A1")->{'Value'} = "A";
$app->Range("B1")->{'Value'} = "B";
$app->Range("B2")->{'Value'} = "C";
$app->Range("C2")->{'Value'} = "D";
$app->Range("A3")->{'Value'} = "E";
$app->Range("B3")->{'Value'} = 10;
$app->Range("C3")->{'Value'} = 10;

# Leave Excel running. Use $app->Quit() to exit.
#$app->Quit();

转载注明地址:http://www.chengxuyuans.com/Perl/63097.html