Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Do you know where your variables are?
 
PerlMonks  

Re: pie chart color -- Win32::OLE

by davies (Vicar)
on Oct 08, 2012 at 14:47 UTC ( #997830=note: print w/ replies, xml ) Need Help??


in reply to pie chart color -- Win32::OLE

I can't reproduce your error, which I would expect to include a line number anyway. But the following code, based on my replies to Prepare charts using Win32::ole, works on Excel 2002. VBA hasn't changed in ways that should make it fail on later versions. If you comment out the last three lines, you should see different colours in the charts.

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->{ChartType} = xlPie; $cht->SetSourceData ({Source=>$sht->Range("A1:B4"), PlotBy=>xlColumns} +); $cht->SeriesCollection(1)->Points(1)->Interior->{Color} = 255; #v +bRed $cht->SeriesCollection(1)->Points(2)->Interior->{Color} = 16711680; #v +bBlue $cht->SeriesCollection(1)->Points(3)->Interior->{Color} = 65280; #v +bGreen

Regards,

John Davies


Comment on Re: pie chart color -- Win32::OLE
Download Code
Reaped: Re^2: pie chart color -- Win32::OLE
by NodeReaper (Curate) on Apr 10, 2013 at 03:46 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997830]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (18)
As of 2014-04-24 13:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (566 votes), past polls