PHPReport icon indicating copy to clipboard operation
PHPReport copied to clipboard

example with template and grouping

Open dfliess opened this issue 11 years ago • 6 comments

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.

dfliess avatar May 06 '13 21:05 dfliess

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...

vernes avatar May 06 '13 22:05 vernes

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.

dfliess avatar May 06 '13 23:05 dfliess

Also what do you think about the subtotal or sum of one field of the group ?

dfliess avatar May 07 '13 00:05 dfliess

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

vernes avatar May 07 '13 13:05 vernes

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 ?

dfliess avatar May 07 '13 20:05 dfliess

@vernes #8

jmb-oliveira avatar Mar 31 '16 17:03 jmb-oliveira