Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

All in all, you are looking at an order of operations issue. Add the data and types to the Chart FIRST, and then add your title, and it should all work out just fine

Make sure to use the Excel Constants WITHOUT quotes. They are constants, after all.

use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE qw(in with); use Win32::OLE::Variant; use Win32::OLE::NLS qw(:LOCALE :DATE); $Win32::OLE::Warn = 3; # Die on Errors. my $vttrue = Variant(VT_BOOL, 1); my $vtfalse = Variant(VT_BOOL, 0); my $Excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit'); $Excel->{DisplayAlerts}=0; $Excel->{Visible} = 1; my $Book = $Excel->Workbooks->Add; my $Sheet = $Book->Worksheets(1); my $Range = $Sheet->Range("A2:C7"); $Range->{Value} = [['TIME', 'QUANTITY', 'PRICE'], ['10:00', 100, 15], ['11:00', 150, 10], ['12:00', 80, 10], ['13:00', 100, 20], ['14:00', 120, 15]]; my $Chart = $Excel->Charts->Add or die; $Chart->{ChartType} =xlLine ; my $series = 1; foreach my $col ("A".."C"){ $Chart->SeriesCollection->Add($Sheet->Range($col."2:".$col."7") +); $Chart->SeriesCollection($series)->{Name}=$Sheet->Range($col."2")->{Va +lue}; $series++; } $Chart->{HasTitle} = $vttrue; $Chart->ChartTitle->{Text} = "My Chart Title";


Flex the Geek

In reply to Re: Using win32::ole on Excel by cacharbe
in thread Using win32::ole on Excel by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (4)
    As of 2021-01-25 03:40 GMT
    Find Nodes?
      Voting Booth?