我在 perl64 上运行以下简单脚本以在 excel 上生成图表,但我在没有生成任何图表的情况下出现以下错误。
它打开excel工作表,将数据写入工作表但没有图表。
Win32::OLE(0.1709) error 0x80020003: "Member not found"
in PROPERTYPUT "ChartType" at C:\path\test.pl line 20.
这是我的系统规格
- PERL 版本:Active Perl 64 v5.16.3
- WIN32 OLE:0.1709
- Excel 版本:Excel 2007 SP3
谁能给我一些关于如何消除此错误并生成图表的意见?
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
my $Excel = Win32::OLE->new("Excel.Application");
$Excel->{Visible} = 1;
$Win32::OLE::Warn = 3;
my $Book = $Excel->Workbooks->Add;
my $Sheet = $Book->Worksheets(1);
my $Range = $Sheet->Range("A2:C7");
$Range->{Value} =
[['Delivered', 'En route', 'To be shipped'],
[504, 102, 86],
[670, 150, 174],
[891, 261, 201],
[1274, 471, 321],
[1563, 536, 241]];
my $Chart = $Excel->Charts->Add;
$Chart->{ChartType} = xlAreaStacked;
$Chart->SetSourceData({Source => $Range, PlotBy => xlColumns});
$Chart->{HasTitle} = 1;