KoolReport's Forum

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

ArrayDataSource export Excel #1007

Open SOFMAN opened this topic on on Jul 23, 2019 - 2 comments

SOFMAN commented on Jul 23, 2019

Good afternoon

Could you help me with an example of how I can export ArrayDataSource to excel, I have it this way: ` <?php

        \koolreport\excel\Table::create(array(
            "dataSources"=>array(
                "array_example_datasource"=>array(
                    "class"=>'\koolreport\datasources\ArrayDataSource',
                    "dataFormat"=>"associate",
                    "data"=>array(
                        array("customerName"=>"Johny Deep","dollar_sales"=>100),
                        array("customerName"=>"Angelina Jolie","dollar_sales"=>200),
                        array("customerName"=>"Brad Pitt","dollar_sales"=>200),
                        array("customerName"=>"Nocole Kidman","dollar_sales"=>100),
                    )
                ),
            )
            ));
    ?>


And in this way I also tried

$this->dataStore('data')->data(array(

array("customerName"=>"Johny Deep","dollar_sales"=>100),
array("customerName"=>"Angelina Jolie","dollar_sales"=>200),
array("customerName"=>"Brad Pitt","dollar_sales"=>200),
array("customerName"=>"Nocole Kidman","dollar_sales"=>100)

)); <?php

    if ($tipoReporte == 1 || $tipoReporte == 3) {
        \koolreport\excel\Table::create(array(
            "dataSource" => $this->dataStore("data")->data()
            ));
    }
   ?>
But when exporting the Excel document does not bring the data.
regards
KoolReport commented on Jul 24, 2019

In the settings function, you do:

function settings()
{
    return array(
"dataSources"=>array(
                "array_example_datasource"=>array(
                    "class"=>'\koolreport\datasources\ArrayDataSource',
                    "dataFormat"=>"associate",
                    "data"=>array(
                        array("customerName"=>"Johny Deep","dollar_sales"=>100),
                        array("customerName"=>"Angelina Jolie","dollar_sales"=>200),
                        array("customerName"=>"Brad Pitt","dollar_sales"=>200),
                        array("customerName"=>"Nocole Kidman","dollar_sales"=>100),
                    )
                ),
            )
    );
}

in the setup() function, you do:

function setup()
{
    $this->src("array_example_datasource")->pipe($this->dataStore("data"));
}

and in the view you do:

        \koolreport\excel\Table::create(array(
            "dataSource" => $this->dataStore("data")
        ));
SOFMAN commented on Jul 24, 2019

THANK YOU

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

Excel