PHPReport
PHPReport copied to clipboard
example with template and grouping
Hi!
First of all thanks for making and publishing this project. I'm trying it and found difficult to make a template with grouping. Can you add an example ? Also is it possible to add functions on the summary ? Example: subtotal or sum of one field of the group ?
Thank you very much in advance.
For grouping, see example 10
'group'=>array(
'caption'=>array(
'cat1'=>'Category 1',
'cat2'=>'Another category'
),
'rows'=>array(
'cat1'=>array(0),
'cat2'=>array(1,2)
),
'summary'=>array(
'cat1'=>array('product'=>'','price'=>23.99,'tax'=>12),
'cat2'=>array('product'=>'','price'=>5.45,'tax'=>5.75)
)
),
In 'caption' array you specify which groups you want, in 'rows' you assign rows for each group and in 'summary' you give row for subtotals (you must calculate subtotals yourself)
I hope this helps...
Thanks for your prompt reply...I tested that example and worked perfect when not using template. I think that my issue is in how to create the template xls.
Also what do you think about the subtotal or sum of one field of the group ?
Unfortunately, you can't use groups with templates.
I'll reopen the issue to see if that feature could be added in the future.
Thanks
I'm looking at the code and I see at render that you call generateReport() if it's using a template instead of createReport and inside that function @line 469 generateRepeatingRowsWithGrouping is called, buy the function name it seems that that's what I'm expecting. That function also uses $this->_group, but I do not understand how that funciton works or how to create the excel template so that the group is repeated, I'm missing something ?
@vernes #8