Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2014-07-25 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls