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

Re: pie chart color -- Win32::OLE

by davies (Prior)
on Oct 08, 2012 at 14:47 UTC ( [id://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

Replies are listed 'Best First'.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-03-29 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found