Perl using Win32::OLE Module Excel 2007- Not Able to Generate Chart

0

I am running following simple script on perl64 to generate chart on excel but I am getting following errors without generating any chart.
It opens excel sheet, write data into sheet but no chart.

Win32::OLE(0.1709) error 0x80020003: "Member not found"
    in PROPERTYPUT "ChartType" at C:\path\test.pl line 20.

Here is my system spec

  • PERL version: Active Perl 64 v5.16.3
  • WIN32 OLE: 0.1709
  • Excel Version: Excel 2007 SP3

Can anyone please give me some input on how I can remove this error and generate chart ?

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;
perl
win32ole
activeperl
asked on Stack Overflow Apr 9, 2013 by user2263994 • edited Apr 9, 2013 by A. Rodas

1 Answer

0

Try to change this line:

 $Chart->SetSourceData({Source => $Range, PlotBy => xlColumns});

to this one:

 $Chart->SetSourceData( $Range, xlColumns );
answered on Stack Overflow Apr 10, 2013 by gangabass

User contributions licensed under CC BY-SA 3.0