I am creating an xlsx-file, and I want to add a column chart, displaying 2 values for a calenderweek.
However, I don't know how many charts (depending on the items available) and how many calenderweeks I'll have to display (depending on the time-frame selected by the user).
Creating the weeks and the data-table is not that problem, that is working fine, iterating through my data with two nested foreach-loops, using setCellValueByColumnAndRow().
My problem is, I have a dynamic number of columns and a dynamic number of rows. So I need a hint, how to transfer
$value = new PHPExcel_Chart_DataSeriesValues('Number',
'Worksheet!$C$9:$H$9',
NULL,
$numberOfWeeks);
array_push($values, $value);
into something like this:
$value = new PHPExcel_Chart_DataSeriesValues('Number',
'Worksheet!$' . $START_COLUMN . '$' . $CURRENT_ROW . ':$' . $END_COLUMN . '$' . $CURRENT_ROW,
NULL,
$numberOfWeeks);
array_push($values, $value);
How do I create the with a chart and a dynamic number of columns?
EDIT:
Within the snippet, there was a missing "!" (Thanks to Mark Barker). Fixed this in my first post.
Because I was using Integer-Values to iterate through the colums, I had to convert the integer back to a letter. A solution for this is posted here.
In the meantime, Mark poked my nose to the function, build in of course ;-) ,
PHPExcel_Cell::stringFromColumnIndex()