Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I am using the below code to generate graph and it is working fine.
use strict; use warnings; use Win32::OLE; use Win32::OLE::Const "Microsoft Excel"; my $xls = Win32::OLE->new('Excel.Application'); $xls->Workbooks->Add(); $xls->{Visible} = 1; $xls->Sheets("Sheet1")->Range('A1')->{Value} = 'Left'; $xls->Sheets("Sheet1")->Range('B1')->{Value} = 'Right'; $xls->Sheets("Sheet1")->Range('C1')->{Value} = 'Center'; for (2 .. 5) { $xls->Sheets("Sheet1")->Range("A$_")->{Value} = $_; $xls->Sheets("Sheet1")->Range("B$_")->{Value} = $_ * 2; $xls->Sheets("Sheet1")->Range("c$_")->{Value} = $_ * 3; } $xls->Charts->Add(); $xls->ActiveChart->SetSourceData({ Source =>$xls->Sheets('Sheet1')->Range("A1:C5"), PlotBy =>xlColumns, }); $xls->ActiveChart->Location({ Where => xlLocationAsObject, Name =>'She +et1'});
But what i want to do is, i want give the values through some variable, ie. the chart should not be generated from the excel data, rather i want to create by giving the values through variables or datastructure. for example, i want to create for the below data. I tried as shown below. How can i achieve that?
my @a = (1, 2, 3); my @b = (5, 10, 15); my $a = \@a; my $b = \@b; $xls->ActiveChart->SetSourceData({ Source =>$xls->Sheets('Sheet1')->Range("$a:$b"), PlotBy =>xlColumns, });
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Generate chart in Excel
by marto (Cardinal) on May 04, 2006 at 12:29 UTC | |
|
Re: Generate chart in Excel
by Fletch (Bishop) on May 04, 2006 at 12:26 UTC | |
|
Re: Generate chart in Excel
by holli (Abbot) on May 04, 2006 at 12:29 UTC | |
|
Re: Generate chart in Excel
by Ponky (Curate) on May 04, 2006 at 23:46 UTC | |
by Anonymous Monk on May 05, 2006 at 14:55 UTC |