Hello,
I'm currently experiencing some problems displaying an Excel graph title. I have two functions, both open an Excel application, enter some data, and generate a graph for the user. Everything works fine except for the graph title in the second function.
Here's the chart code for the working function.
sub Res_stdd_Click
{
my $chart;
...
...
# Create chart
$chart = $xlBook->Charts->Add;
$chart->SetSourceData($rng, 2);
$chart->{ChartType} = 58; # Bar graph
$chart->ChartTitle->{Text} = "Std. Dev. HSDL/GWY/SSMS";
$chart->Location(1, "CHART");
...
...
return;
}
Below is the code in which everything works except the chart title does not show up.
sub Res_wave_Click
{
my $chart;
...
...
# Create chart
$chart = $xlBook->Charts->Add;
$chart->SetSourceData($rng, 2);
$chart->{ChartType} = 73; # line graph
$chart->ChartTitle->{Text} = "HSDL/GWY/SSMS Waveforms";
$chart->Location(1, "CHART");
...
...
return;
}
As you can see the code is almost completely identical except for the chart type, which is necessary. In fact, the code is directly from the Microsoft's example on using PERL with Excel. I am aware of a bug in $chart->Location that causes $chart to become invalid so it's called last. I also tried $chart->HasTitle = 1, but it throws an error detailing a non-lvalue reference. Furthermore, I have also tried accessing the title by $chart->ChartTitle->Characters->{Text}, but this throws "Can't use an undefined value as a Hash reference." error.
Anyone have any ideas on why I am experiencing this behavior? Or am I just simple using the wrong chart type?
Thanks in advice!
------
Matthew King
MaKing@nbpower.com
Computer Design & System Performance,
Pt. Lepreau Nuclear Generating Station,
NB Power,
Maces Bay, N.B.,
I'm currently experiencing some problems displaying an Excel graph title. I have two functions, both open an Excel application, enter some data, and generate a graph for the user. Everything works fine except for the graph title in the second function.
Here's the chart code for the working function.
sub Res_stdd_Click
{
my $chart;
...
...
# Create chart
$chart = $xlBook->Charts->Add;
$chart->SetSourceData($rng, 2);
$chart->{ChartType} = 58; # Bar graph
$chart->ChartTitle->{Text} = "Std. Dev. HSDL/GWY/SSMS";
$chart->Location(1, "CHART");
...
...
return;
}
Below is the code in which everything works except the chart title does not show up.
sub Res_wave_Click
{
my $chart;
...
...
# Create chart
$chart = $xlBook->Charts->Add;
$chart->SetSourceData($rng, 2);
$chart->{ChartType} = 73; # line graph
$chart->ChartTitle->{Text} = "HSDL/GWY/SSMS Waveforms";
$chart->Location(1, "CHART");
...
...
return;
}
As you can see the code is almost completely identical except for the chart type, which is necessary. In fact, the code is directly from the Microsoft's example on using PERL with Excel. I am aware of a bug in $chart->Location that causes $chart to become invalid so it's called last. I also tried $chart->HasTitle = 1, but it throws an error detailing a non-lvalue reference. Furthermore, I have also tried accessing the title by $chart->ChartTitle->Characters->{Text}, but this throws "Can't use an undefined value as a Hash reference." error.
Anyone have any ideas on why I am experiencing this behavior? Or am I just simple using the wrong chart type?
Thanks in advice!
------
Matthew King
MaKing@nbpower.com
Computer Design & System Performance,
Pt. Lepreau Nuclear Generating Station,
NB Power,
Maces Bay, N.B.,