我有以下代碼:你可以調用一個數組元素的方法嗎?
my $workbook = Excel::Writer::XLSX->new('a_simple.xlsx');
my $worksheet = $workbook->add_worksheet();
my @chart_performance1 = $workbook->add_chart(type => 'column', embedded => 1);
my $no_of_titles = 3;
for (my $no_of = 0; $no_of < $no_of_titles; $no_of++) {
$chart_performance1[ $no_of ]->add_series(
name => $chart_heading[ 0 ],
categories => [ 'Sheet1', $array_game_titles[ $no_of ] , $row_range_max , 0, 0 ],
values => [ 'Sheet1', $array_game_titles[ $no_of ] , $row_range_max , 1, 1 ],
);
}
當我運行它,我得到的錯誤:
Can't call method "add_series" on an undefined value
爲什麼?
你的問題是什麼? – ThisSuitIsBlackNot
我們可以用這種方式調用模塊函數「add_series」。 – LohitRaj
@LohitRaj當你嘗試時會發生什麼?閱讀有很多例子的文檔。 –