use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; my $xl = Win32::OLE->new('Excel.Application'); $xl->{Visible} = 1; my $wb = $xl->Workbooks->Add; my $sht = $wb->Sheets(1); $sht->Range("A1")->{Value} = "'PMD"; $sht->Range("A2")->{Value} = "'SOPW"; $sht->Range("A3")->{Value} = "'Meds"; $sht->Range("A4")->{Value} = "'CUFP"; $sht->Range("B1")->{Value} = "3"; $sht->Range("B2")->{Value} = "40"; $sht->Range("B3")->{Value} = "2"; $sht->Range("B4")->{Value} = "1"; my $cht = $wb->Charts->Add; $cht->Location ({Where=>xlLocationAsObject, Name=>$sht->Name}); $cht = $sht->ChartObjects(1)->Chart; $cht->{ChartType} = xlPie; $cht->SetSourceData ({Source=>$sht->Range("A1:B4"), PlotBy=>xlColumns}); $cht->{AutoScaling} = 0; $cht->PlotArea->{Width} = 190; $cht->PlotArea->{Height} = 191; $cht->SeriesCollection(1)->Points(1)->Interior->{Color} = 255; #vbRed - NOT an Excel constant, but a VBA constant