Perl Win32::OLE Microsoft Excel Set font size in chart legend and datatable

Posted on 2008-11-16
Last Modified: 2012-08-14
I'm not a Perl programmer and have inherited a Perl script that uses OLE animation to create data and charts in an Excel spreadsheet.

The charts have a terrible appearance primarily due to text font sizes -- at the normal 10-point size they take up enough room that the actual graph gets compressed and becomes useless.  I've made the charts look good in Excel by reducing the text point sizes -- I've set them to 3-point at the moment.

I've been able to update the Perl script to set font sizes for the chart title and the X and Y axis titles.

My problem is that I can't seem to do the same for the datatable and legend fonts.  The attached source contains
   #Not a CODE reference
just before each of the two commented out lines representing my attempts to the set font sizes.  "Not a CODE reference" is the problem I'm seeing for each.
Question by:josgood
    LVL 13

    Author Comment

    Added Excel forum.
    LVL 25

    Accepted Solution

    The error you're getting is caused by the parens.  They should be curly brackets:

      $chart->(DataTable)->{Font}->{Size} = 3;

    Should be:

      $chart->{DataTable}->{Font}->{Size} = 3;


      $chart->(Legend)->{Font}->{Size} = 3;

    Should be:

      $chart->{Legend}->{Font}->{Size} = 3;

    Don't have excel to test that Legend and Datatable are objects of a chart (and if they are whether they have a font object with a size property), but assuming that the following would work in vba:

      chart.Legend.Font.Size = 3


      chart.Datatable.Font.Size = 3

    then the above bracketed version should work in perl.
    LVL 13

    Author Closing Comment

    Thank you!

    That is exactly the answer I needed.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now