perl_learner211 has asked for the wisdom of the Perl Monks concerning the following question:

I hope I'm posting my question in the correct area regarding using WIN32::OLE Excel in Perl.
Question:
How do I change the Primary axis (scaling) for a chart? Or the "type" of the axis (I know there are three types: Automatic, Category, and Time-scale). I supposed I need it to be "Category".
$Chart->{ChartType} = xlXYScatterLines; $Chart->SetSourceData({Source => $Range, PlotBy => xlColumns});
Example data:
x-axisPoint1 Point2
7.1 72.02% 81.06%
7.5 58.06% 36.94%
7.6 58.17% 65.26%
8.6 11.10% 87.15%

I want x-axis to be shown as "7.1", "7.5", "7.6", "8.6" and not Range from 7.0 to 9.0 with scale 0.2

Please help. Thanks in advance.

Replies are listed 'Best First'.
Re: Perl (WIN32::OLE) Excel help -- Chart Axis Scaling
by Corion (Patriarch) on Apr 21, 2009 at 06:06 UTC
      Hi, when I did a Macro. I saw the codes generated
      ...Axes.TickLabelSpacing = 1;

      Then I do the following in perl:

      ...$Xaxes->{TickLabelSpacing} = 1;

      And it said there was an error, so I did the following:

      ...$Xaxes->{TickLabelSpacing}->{Value} = 1;

      error:
      OLE exception from "Microsoft Office Excel":
      Unable to get the TickLabelSpacing property of the Axis class
      Win32::OLE(0.1709) error 0x80020009: "Exception occurred" in METHOD/PROPERTYGET "TickLabelSpacing" at ...

      And I saw it on
      http://msdn.microsoft.com/en-us/library/aa218119(office.10).aspx

      ChartSpace1.Charts(0).Axes(1).TickLabelSpacing = 2

      I'm not sure where to go from here.
        And it said there was an error,

        What</ error, and who said there was one?

        If the documentation says that TickLabelSpacing is a property, then you can also try

        ->LetProperty('TickLabelSpacing', $OtherObject);

        (as the Win32::OLE documentation says), or a SetProperty call to do what you want.