我在perl64上运行以下简单脚本来生成excel上的图表但是我收到了以下错误而没有生成任何图表。
它打开Excel工作表,将数据写入工作表但没有图表。
Win32::OLE(0.1709) error 0x80020003: "Member not found"
in PROPERTYPUT "ChartType" at C:\path\test.pl line 20.
这是我的系统规范
有人可以就如何删除此错误并生成图表给我一些意见吗?
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;
答案 0 :(得分:0)
尝试更改此行:
$Chart->SetSourceData({Source => $Range, PlotBy => xlColumns});
到这一个:
$Chart->SetSourceData( $Range, xlColumns );