KoolReport's Forum

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

Call to a member function meta() on array #2360

Closed Javier Córdova opened this topic on on Sep 28, 2021 - 4 comments

Javier Córdova commented on Sep 28, 2021

Hi friends!, I have a problem when I trying export to Excel

My report is:

function setup()
    {
        $fecha_inicio = $this->params["fecha_inicio"];
        $fecha_fin = $this->params["fecha_fin"];
        $cod_perfil = $this->params["cod_perfil"];

        $myData = 'SELECT * FROM reporte_concurrencia(\''. $fecha_inicio .'\',\''.  $fecha_fin .'\', '. $cod_perfil .')' ;
        
        $node2 = (object)[];

        $this->src("pgsql") //<--config/database
        ->query(
            $myData
        )->saveTo($node2);
        $node2->pipe($this->dataStore('concurrencia'));

        $node2->pipe(new Transpose2())->pipe($this->dataStore('concurrencia_cube'));
        
    }

dataStore('concurrencia_cube') I am using in the report view:

and with this I am trying to get the data from the columns (names etc) $data = $this->dataStore("concurrencia_cube")->data(); $columnsMeta = $this->dataStore("concurrencia_cube")->meta()["columns"]; but I get the following error: "Call to a member function meta() on array"

I hope you can help me! Javier

Sebastian Morales commented on Sep 29, 2021

Pls post your excel view code and which datasource you use for its Table, which should be a datastore, not an array. Rgds,

Javier Córdova commented on Sep 29, 2021

Hi Sebastián, thank you for your response,

In this way I am loading the data to my AreaChart, but I comment that in the view if it works perfectly, when I send to export to excel the exception shown above jumps.

Sebastian Morales commented on Sep 30, 2021

I think so far all of Excel widgets (Table, Charts) only accepts a DataStore object as "dataSource". If you have the data and meta you could create a DataStore object and pass it to Excel widget like this:

$ds = new \koolreport\core\DataStore($newData, $newMeta);
AreaChart::create(array(
    "dataSource" => $ds,
    ...
));
Javier Córdova commented on Sep 30, 2021

Thank you very much for your answer Sebastian, now I understand, when I use modified data source, I must convert to DataStore object. Thanks for the help, it worked perfect now.

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