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

Re: Using win32::ole on Excel

by cacharbe (Curate)
on Oct 28, 2002 at 18:07 UTC ( #208568=note: print w/replies, xml ) Need Help??


in reply to Using win32::ole on Excel

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";

C-.

---
Flex the Geek

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://208568]
help
Chatterbox?
[Discipulus]: .. yes erix until NodeReaper put jhon coltrane again
[erix]: nice cover with the spitting image of George (and a great solo by Prince at the end )
[Discipulus]: good night monks! i feel fresh as the turkey in the hoven but i need to sleep
[planetscape]: gobble, gobble, Discipulus!
[erix]: Discipulus: buonanotte! :)
[stonecolddevin]: man we need a new guitar legend
[stonecolddevin]: Clapton has issues playing nowadays
[stonecolddevin]: Prince is gone
[stonecolddevin]: Van Halen is still around but I haven't heard any of their new stuff
[erix]: oh, 41M views -- everyone has seen it already then :)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-06-22 21:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.