Perl 使用 OLE 自动化来创建 Excel 图表

2015-12-14 0 814
Perl 使用 OLE 自动化来创建 Excel 图表
#!/usr/bin/perl -w

use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';

$class = 'Excel.Application';

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


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

# Create a new workbook.
$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;


#
# Make a chart.
#
$worksheet   = $workbook->Worksheets(1);

$chart_range = $worksheet->Range("B3:C3");

$chart = $app->Charts->Add();

#$chart->{'ChartType'} = xlAreaStacked;

$chart->SetSourceData(
    {
    Source => $chart_range,
    PlotBy => xlColumns
    } );

$chart->{'HasTitle'} = 1;
$chart->ChartTitle->{'Text'} = "Chart Title";

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

遇见资源网 perl Perl 使用 OLE 自动化来创建 Excel 图表 http://www.ox520.com/13217.html

上一篇:

已经没有上一篇了!

下一篇:

已经没有下一篇了!

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务