This should get you started. I snipped this from some of my Excel chart stuff.
use strict;
use Win32::OLE qw( in with );
use Win32::OLE::Variant;
use Win32::OLE::Const 'Microsoft Excel';
use constant True=> 1;
use constant False=> 0;
my $Excel = Win32::OLE->new('Excel.Application', 'Quit') or die "$!";
$Excel->{'Visible'} = 1;
my $Wkbook = $Excel->Workbooks->Add();
my $sheet1 = $Wkbook->Worksheets(1);
#sample data
$sheet1->Range("U10:W12")->{Value} = [[ 10, 20, 30 ],
[ 5, 10, 20 ], [ 20, 7, 12 ]
+ ];
my $range = $sheet1->Range( "U10:w12");
#add position, size chart1
my $chartObj = $sheet1->ChartObjects->Add( 2, 2, 600, 290 );
my $chart = $chartObj->Chart;
$chart->SetSourceData($range);
with($chart, HasLegend=> False , HasTitle=>True);
$range = $sheet1->Range("U10:W12");
#add position, size chart2
my $chartObj2 = $sheet1->ChartObjects->Add( 2, 300, 600, 290 );
my $chart2 = $chartObj2->Chart;
$chart2->SetSourceData($range);
my $sc = $chart2->SeriesCollection(1);
my $sc2 = $chart->SeriesCollection(1);
my $ax2 = $chart2->Axes;
my $ax = $chart->Axes;
with($chart2, HasLegend=> False , HasTitle=> True );
with($chart2->PlotArea->Border, Color=>0, LineStyle=> -4142, ColorI
+ndex => -4142);
with($chart2->PlotArea->Interior, Color=> 16777215 );
with($chart2->ChartArea->Font, Size=> 8 );
with($chart->PlotArea->Interior, ColorIndex=>-4142 );
with($chart, HasLegend=> False , HasTitle=> True );
with($chart->PlotArea->Border, Color=>0, LineStyle=> -4142, ColorIn
+dex => -4142);
with($chart->PlotArea->Interior, Color=> 16777215 );
with($chart->ChartArea->Font, Size=> 8 );
my $pt = $sc->Points;
my $pt2 = $sc2->Points;
with( $chart2->ChartTitle, Text => 'Chart 2 Title');
with( $chart2->ChartTitle->Font, Name=> 'Arial', Size=>14, Bold=>Tru
+e );
with( $chart->ChartTitle, Text => 'Chart 1 Title');
with( $chart->ChartTitle->Font, Name=>'Arial', Size=>14, Bold=>True
+);
with( $ax->Item(xlValue), HasTitle => True);
with( $ax2->Item(xlValue), HasTitle => True);
with( $ax2->Item(xlValue)->AxisTitle, Text => "Balance(\$ millions)"
+);
with( $ax->Item(xlValue)->AxisTitle, Text => "Frequency");
with( $ax2->Item(xlValue)->TickLabels, NumberFormat => "\$#,##0");
with( $ax->Item(xlCategory), HasTitle => True);
with( $ax2->Item(xlCategory), HasTitle => True);
with( $ax2->Item(xlCategory)->AxisTitle, Text => "Age (Months)");
with( $ax->Item(xlCategory)->AxisTitle, Text => "Age (Months)");
with( $sc->Interior, Color => 6697881 );
JamesNC
|