Problem with Name of Excel Chart

Discussion in 'Perl Misc' started by paul.porcelli@scottishwater.co.uk, Sep 22, 2005.

  1. Guest

    Hi folks,
    I have a perl script which produces a 4 worksheet Excel spreadsheet and
    4 accompanying Excel Charts.
    The data all looks fine but I have a problem I cannot solve.
    I produce the charts via a loop in the script which loops 4 times.
    For each chart, I want to name them according to the value of an array
    i.e.
    my @location=qw/loc1 loc2 loc3 loc4/;

    However the name on each Chart is never changed, so they are labelled
    Chart1, Chart2 etc.

    I tried changing the $location to "TEST" but all this does is to change
    Chart1 to "TEST". Charts 2,3 and 4 are not changed.

    N.B. This loop is used to rename the Worksheet labels also and that
    works fine.

    Any help most welcome.
    Thanks.
    Thanks.
    Paul


    $Range = $Sheet->Range($cellend);

    my $Chart = $Book->Charts->Add;
    $Chart->{ChartType} = xlLineMarkers;
    $Chart = $xl->ActiveChart;
    $Chart->{Name} = 'TEST';
    $Chart->SetSourceData({Source => $Range, PlotBy => xlColumns});
    $Chart->{HasTitle} = 1;
    $Chart->ChartTitle->{Text} = $location;
    $Chart->Axes(xlCategory, xlPrimary)->{HasTitle} = 1;
    $Chart->Axes(xlCategory, xlPrimary)->AxisTitle->{Text} = "Time";
    $Chart->Axes(xlValue, xlPrimary)->{HasTitle} = 1;
    $Chart->Axes(xlValue, xlPrimary)->AxisTitle->{Text} = "Milliseconds";
     
    , Sep 22, 2005
    #1
    1. Advertising

  2. Bob Walton Guest

    wrote:

    ....
    > I have a perl script which produces a 4 worksheet Excel spreadsheet and
    > 4 accompanying Excel Charts.
    > The data all looks fine but I have a problem I cannot solve.
    > I produce the charts via a loop in the script which loops 4 times.
    > For each chart, I want to name them according to the value of an array
    > i.e.
    > my @location=qw/loc1 loc2 loc3 loc4/;


    You give values to elements of @location here, but in your code
    below, you use $location. Those two variables have absolutely
    nothing to do with each other. What is your real code (that is,
    how did $location receive a value)? Also, it would be most
    helpful if you could post short but complete code that
    illustrates your problem that anyone can copy/paste/run without
    further ado, as the posting guidelines for this newsgroup
    require. You'll get much better responses.

    >
    > However the name on each Chart is never changed, so they are labelled
    > Chart1, Chart2 etc.
    >
    > I tried changing the $location to "TEST" but all this does is to change
    > Chart1 to "TEST". Charts 2,3 and 4 are not changed.
    >
    > N.B. This loop is used to rename the Worksheet labels also and that

    -------^^^^^^^^^
    What loop? Your posted code doesn't have a loop.
    > works fine.

    ....
    > Paul
    >
    >
    > $Range = $Sheet->Range($cellend);
    >
    > my $Chart = $Book->Charts->Add;
    > $Chart->{ChartType} = xlLineMarkers;
    > $Chart = $xl->ActiveChart;
    > $Chart->{Name} = 'TEST';
    > $Chart->SetSourceData({Source => $Range, PlotBy => xlColumns});
    > $Chart->{HasTitle} = 1;
    > $Chart->ChartTitle->{Text} = $location;
    > $Chart->Axes(xlCategory, xlPrimary)->{HasTitle} = 1;
    > $Chart->Axes(xlCategory, xlPrimary)->AxisTitle->{Text} = "Time";
    > $Chart->Axes(xlValue, xlPrimary)->{HasTitle} = 1;
    > $Chart->Axes(xlValue, xlPrimary)->AxisTitle->{Text} = "Milliseconds";
    >

    --
    Bob Walton
    Email: http://bwalton.com/cgi-bin/emailbob.pl
     
    Bob Walton, Sep 24, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Shade

    Excel Chart SeriesCollection Error

    Brian Shade, Sep 9, 2004, in forum: Perl
    Replies:
    0
    Views:
    1,002
    Brian Shade
    Sep 9, 2004
  2. =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=

    Problem with Excel reports ::::Excel 2003 Migration To Excel 2007

    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=, Oct 5, 2007, in forum: ASP .Net
    Replies:
    15
    Views:
    1,518
    =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?=
    Oct 24, 2007
  3. gnewsgroup
    Replies:
    4
    Views:
    3,013
    Kevin Spencer
    Feb 6, 2008
  4. Tarek
    Replies:
    6
    Views:
    319
    Chris Hohmann
    Nov 19, 2004
  5. Replies:
    1
    Views:
    832
Loading...

Share This Page