Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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


John Davies

Comment on Re: pie chart color -- Win32::OLE
Download Code
Replies are listed 'Best First'.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2015-11-29 03:16 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (746 votes), past polls