Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Excel and Win32::OLE chart problems

by bmann (Priest)
on Oct 30, 2007 at 19:04 UTC ( #648085=note: print w/replies, xml ) Need Help??

in reply to Excel and Win32::OLE chart problems

The object $chart is an Excel ChartObject, which contains a Chart object, which has a property ChartType. In Excel, that'd be chart.Chart.ChartType In perl,

$chart->ChartType} = xl3DColumnClustered;
should be
$chart->Chart->{ChartType} = ...

Replies are listed 'Best First'.
Re^2: Excel and Win32::OLE chart problems
by the_hawk_1 (Scribe) on Oct 30, 2007 at 19:47 UTC

    That fix the "style" of the graph!

    Unfortunately, I still didn't get the XAxis Values.

    Did you still get enough time to help me again?

    Here's my *new* code

    # Create the chart # $chart = $sheet->ChartObjects->Add(1, 175, 457, 300); $chart->Chart->{ChartType} = xl3DColumnClustered; $chart->Chart->ChartWizard({Source =>$sheet->Range("D5:D12")}); $chart->Chart->SeriesCollection(1)->{XValues}=$sheet->Range("D5:D12"); $chart->Chart->SeriesCollection(1)->{HasDataLabels} = 1; $chart->Chart->SeriesCollection(1)->Interior->{ColorIndex} = 36; $chart->Chart->{HasLegend} = $vtfalse; $chart->Chart->{HasDataTable} = $vtfalse; with ($chart->Chart, 'Elevation' => 15, 'Perspective' => 0, 'Rotation' => 20, 'RightAngleAxes' => $vttrue, 'HeightPercent' => 100, 'AutoScaling' => $vttrue); with ($chart->Chart->Axes(xlCategory), 'TickLabelSpacing' => 1, 'TickMarkSpacing' => 1);
    Thanks again!
      If I understand your question correctly, the values in B5-B12 should be the XAxis labels, right?

      If so, use that range as the source data for the chart, ie

      $chart->Chart->ChartWizard({Source => $sheet->Range("B5:B12,D5:D12")};
      instead of just D5:D12. I believe that the two SeriesCollection lines are the defaults, so they shouldn't be necessary. Keep the ColorIndex line though.

        Sorry to give you such a bad news, but now I've moved backwards: I've lost all the data in the chart! Is it possible to avoid the chartWizard?!?

        Update:It works! we just need a ; instead of a , in the range line.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://648085]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2018-05-26 06:41 GMT
Find Nodes?
    Voting Booth?