http://www.perlmonks.org?node_id=959087


in reply to Generating an Excel chart

Spreadsheet::WriteExcel provides a utility function called xl_range_formula()to deal with this.

See the Working with cell ranges section of the chart documentation:

$chart->add_series( categories => xl_range_formula( 'Sheet1', 1, 9, 0, 0 ), values => xl_range_formula( 'Sheet1', 1, 9, 1, 1 ), );

Note, if you are creating an Excel 2007 workbook and chart then you could consider using Excel::Writer::XLSX. It has a slightly easier interface for this case:

$chart->add_series( categories => '=Sheet1!$A$2:$A$7' ); # Sa +me as ... $chart->add_series( categories => [ 'Sheet1', 1, 6, 0, 0 ] ); # Ze +ro-indexed.

--
John.