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

Hi,

I've ask this question earlier, since its kinda urgent for me so I just post it again. I am trying use perl to automate the process of executing a program, process the the result and present the data in Excel. I ve followed the samples in your site and some other resources, but the win32::ole function didnt work very well with excel in my case:

I can create a workbook, insert data and create a new chart with perl in excel, however, I cannot change the chart type, set the tile, axis title or run a macro.

I use the following code to

#create chart and title: my $Chart = $ex->Charts->Add; $Chart->{HasTitle} = 1; my($title)="Analysis Result ".$fileIndex; $Chart->ChartTitle->{Text} = $title; #define cahrt type: $Chart->{ChartType} = "xlLineMarkers"; $Chart->Location({Where => "xlLocationAsNewSheet"}); #set axis title: my $Xaxes = $Chart->Axes("xlCategory", "xlPrimary"); $Xaxes->{HasTitle} = 1; $Xaxes->{AxisTitle}->{Characters}->{Text} = "X Title"; my $Yaxes = $Chart->Axes("xlValue", "xlPrimary"); $Yaxes->{HasTitle} = 1; $Yaxes->{AxisTitle}->{Characters}->{Text} = "Y Title";

I ve put all this in the perl program but it has no effect, the chart always diplay as bar charts, and I can use perl to delete and data set in it.

Also If I insert the data first and create chart, as I can remove the data set, it alwasy give me the wrong data set in chart.

what's wrong with the code, I really dont know, are there any setting that I need to set on excel to use this function?

thanks!

Replies are listed 'Best First'.
Re: win32::ole question again
by dada (Chaplain) on Oct 28, 2002 at 15:03 UTC
    you should remove all the quotes from the xlXXX literals. they're constants, not strings. eg:
    $Chart->{ChartType} = xlLineMarkers; $Chart->Location({Where => xlLocationAsNewSheet});
    also make sure you have this line at the beginning of your script:
    use Win32::OLE::Const 'Microsoft Excel';
    hope this helps...

    cheers,
    Aldo

    King of Laziness, Wizard of Impatience, Lord of Hubris

Re: win32::ole question again
by AcidHawk (Vicar) on Oct 28, 2002 at 14:47 UTC

    hmmm... this may not be what you are looking for.. but if you are only using excel to build a graph.. have you looked at GD::Graph

    -----
    Of all the things I've lost in my life, its my mind I miss the most.