KoolReport's Forum

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

Export excel result sheet name not match #3329

Open saiful opened this topic on on Aug 29 - 8 comments

saiful commented on Aug 29

hi, i'm using excel package to export data from array to xlsx, the file was generated successfully, but the result has 2 sheet like this

the resulting sheet name doesn't match the name I defined. and I didn't set the chart_data sheet anywhere, but it was created automatically, I want to delete it.

here is my code:

public function settings()
    {
        return array(
            "dataSources"           => [
                "paramData"         => array(
                    "class"         => '\koolreport\datasources\ArrayDataSource',
                    "data"          => $this->params,
                    "dataFormat"    => "associate",
                )
            ]
        );
    }

    public function setup()
    {
        $this->src('paramData')
        ->pipe($this->dataStore('exceldata'));
    }

this is the excel view:

<?php

    use \koolreport\excel\Table;
    $sheet1 = "EXCEL REPORT AUTOMAIL";

?>

<meta charset="UTF-8">
<meta name="description" content="<?php echo $sheet1; ?>">
<meta name="keywords" content="Excel,HTML,CSS,XML,JavaScript">
<meta name="subject" content="<?php echo $sheet1; ?>">
<meta name="title" content="<?php echo $sheet1; ?>">
<meta name="category" content="category1">

<!-- sheet 1 -->
<div sheet-name="<?php echo $sheet1; ?>">
    
    <div>
    <?php
        Table::create(array(
            "dataSource"        => $this->dataStore("exceldata"),
            "rowHeight" => function($row, $rowIndex) {
                // return 'auto';
                return 10 * ($rowIndex + 1);            # ---> not working?
            },
            "columnWidth" => function($columnName, $columnIndex) {
                if ($columnName === "voucher_type") return '10';
                else return 'auto';                     # ---> not working?
            }, 
            "excelStyle" => [
                "columnAutoSize"=> true,
                "header" => function($colName) { 
                    return [
                        'font' => [
                            'italic' => false,
                            'bold' => true,
                            'color' => [
                                'rgb' => '000000',
                            ]
                        ],
                        'alignment' => [
                            'horizontal' => 'center',//left, right, center, centerContinuous, justify, fill, distributed
                            'vertical' => 'center',//top, center, justify, distributed
                            'textRotation' => 0,
                            'wrapText' => false,
                        ]
                    ]; 
                },
            ]
        ));
    ?>
    </div>
   
</div>
Sebastian Morales commented on Aug 29

Oh, I think this is a bug in the current version of Excel package. We will fix it soon in the next release of KoolReport.

saiful commented on Aug 29

so i need to use older version of excel package?

Sebastian Morales commented on Aug 29

Or you can open the file koolreport/excel/ExportHandler.php and uncomment the following lines from:

        // if (Util::get($config, 'hideChartDataSheet', true)) {
        //     $chartDataSheet->setSheetState(ps\Worksheet\Worksheet::SHEETSTATE_HIDDEN);
        // }

to:

        if (Util::get($config, 'hideChartDataSheet', true)) {
            $chartDataSheet->setSheetState(ps\Worksheet\Worksheet::SHEETSTATE_HIDDEN);
        }
saiful commented on Sep 3

thanks, the additional sheet is removed, but the sheet name still exceldata

Sebastian Morales commented on Sep 4

Pls try to export the following excel view and let us know the result of the first sheet name:

<div sheet-name="Sheet1">
    
    <div>
        Hello world
    </div>
   
</div> 

If it works correctly then try this one:

<div sheet-name="Sheet1">
    
    <div>
        <?php
        \koolreport\excel\Table::create(array(
            "dataSource"        => $this->dataStore("exceldata"),
            "rowHeight" => function($row, $rowIndex) {
                // return 'auto';
                return 10 * ($rowIndex + 1);            # ---> not working?
            },
            "columnWidth" => function($columnName, $columnIndex) {
                if ($columnName === "voucher_type") return '10';
                else return 'auto';                     # ---> not working?
            }, 
            "excelStyle" => [
                "columnAutoSize"=> true,
                "header" => function($colName) { 
                    return [
                        'font' => [
                            'italic' => false,
                            'bold' => true,
                            'color' => [
                                'rgb' => '000000',
                            ]
                        ],
                        'alignment' => [
                            'horizontal' => 'center',//left, right, center, centerContinuous, justify, fill, distributed
                            'vertical' => 'center',//top, center, justify, distributed
                            'textRotation' => 0,
                            'wrapText' => false,
                        ]
                    ]; 
                },
            ]
        ));
    ?> 
    </div>
   
</div> 
saiful commented on Sep 4

hello, it's not working, the results are exactly the same as before

Sebastian Morales commented on Sep 5

It looks like you export a datastore directly instead of via an excel view file. Pls try to use excel template export like this:

https://www.koolreport.com/docs/excel/export_to_excel/#excel-export-template-(version-%3E=-6.0.0)

saiful commented on Sep 5

ah yes, it's 100% worked, the styling properties also applied. thank you very much

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
bug
help needed
solved

Excel