KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Subtotal on table not display using excel table #2760

Open saiful opened this topic on on Jul 22, 2022 - 5 comments

saiful commented on Jul 22, 2022

hi, im using excel table to display and export report to excel file, but in my report there's no subtotal row, i've tried to use properties "hideSubtotalRow=false" but it does't affect anything. how can i display subtotal on my excel table?

and one again, i use "excel style" to aligning data on my report, but the result has no affected too

Sebastian Morales commented on Jul 22, 2022

Excel Table has no "hideSubTotalRow" property. Kindly point out in the screenshot which rows you want to hide. We will see if there's a solution or if we can implement it in the future.

As for excel style, I can only see you style table headers to be center, no datacell's style in your screenshots. Pls post the code (in text, not screenshot) for cell's style if the end result is not what you want.

saiful commented on Jul 22, 2022

1.) i need to display the subtotal row before total row (bold row on previous pic), it doesn't displayed yet, i thought it can displayed using " hideSubtotalRow = false " properties.

2.) this is the excel styling code:


            "excelStyle" => [
                "header" => function($colName) { 
                    return [
                        'font' => [
                            'italic' => false,
                            'bold' => true,
                            'color' => [
                                'rgb' => '800000',
                            ]
                        ],
                        'alignment' => [
                            'horizontal' => 'center',//left, right, center, centerContinuous, justify, fill, distributed
                            'vertical' => 'center',//top, center, justify, distributed
                    ]];
                },
                //"bottomHeader" => function($colName) { return []; },
                "cell" => function($colName, $value, $row) { 
                    switch($colName){
                        
                        case "no":
                            return [
                                        'alignment' => [
                                            'horizontal' => 'center',//left, right, center, centerContinuous, justify, fill, distributed
                                            'vertical' => 'center',//top, center, justify, distributed
                                        ],
                                    ];                        
                        break;
                        case "job_no":
                            return [
                                        'alignment' => [
                                            'horizontal' => 'center',//left, right, center, centerContinuous, justify, fill, distributed
                                            'vertical' => 'center',//top, center, justify, distributed
                                        ],
                                    ];                        
                        break;
                        case "job_dt":
                            return [
                                        'alignment' => [
                                            'horizontal' => 'center',//left, right, center, centerContinuous, justify, fill, distributed
                                            'vertical' => 'center',//top, center, justify, distributed
                                        ],
                                    ];                        
                        break;
                        case "qty":
                            return [
                                        'alignment' => [
                                            'horizontal' => 'center',//left, right, center, centerContinuous, justify, fill, distributed
                                            'vertical' => 'center',//top, center, justify, distributed
                                        ],
                                    ];                        
                        break;
                        case "curr":
                            return [
                                        'alignment' => [
                                            'horizontal' => 'center',//left, right, center, centerContinuous, justify, fill, distributed
                                            'vertical' => 'center',//top, center, justify, distributed
                                        ],
                                    ];                        
                        break;
                    }
                     
                },
                //"footer" => function($colName, $footerValue) { return []; },
            ],



Sebastian Morales commented on Jul 25, 2022

1 . Excel table's row group has a "bottom" property to show result at the bottom of a group instead of "top":

            "rowGroup" => [
                "customerName" => [
                    ...
                    // "top" => "Top: Customers: {customerName}",
                    // "columnTops" => [
                    //     "dollar_sales" => "{totalSales}"
                    // ],
                    "bottom" => "Bottom: Customers: {customerName}", 
                    "columnBottoms" => [
                        "dollar_sales" => "{totalSales}"
                    ],

You might want to see if it serves your purpose.

2 . Pls try to return "alignment" directly to see if it works:

            "excelStyle" => [
                ...
                "cell" => function($colName, $value, $row) { 
                            return [
                                        'alignment' => [
                                            'horizontal' => 'center',//left, right, center, centerContinuous, justify, fill, distributed
                                            'vertical' => 'center',//top, center, justify, distributed
                                        ],
                                    ];  
                },
saiful commented on Jul 25, 2022

thanks, that's work, but for my question no. 2, the subtotal row don't affect to the cell styling

how to align the subtotal row?

Sebastian Morales commented on Jul 25, 2022

If you want to apply style for row group rows, "cell" is not what you want, instead use "rowGroup" like this:

            "excelStyle" => [
                ...
                "rowGroup" => function($rgField, $rgValue, $colName) {
                    return [
                        ...
                    ];
                }
            ] 

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

Excel