KoolReport's Forum

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

How to Export Subreport #2725

Closed George opened this topic on on Jun 14, 2022 - 1 comments

G
George commented on Jun 14, 2022

Hi,

Usually for a normal report I'm exporting my report with

require_once REPORT_LOC . '/MyReport.php';
$report = new MyReport();
           $report->export($report_template_str)
                       ->settings([
                                      "useLocalTempFolder"      => TRUE,
                                      "autoDeleteLocalTempFile" => TRUE,
                                      "phantomjs"               => $phantom_dir
                                  ])
                       ->pdf(["format" => "A4", 'orientation' => "landscape", "zoom" => 0.5])
                       ->saveAs($file_directory . $file_name);

For a different report, I have a subreport thats also included using the Subreport package. I have a MyReport.php file that imports the MainTable.php and SubTable.php

<?php

require "MainTable.php";
require "SubTable.php";

class MyReport extends \koolreport\KoolReport {
    use \koolreport\core\SubReport;
    use \koolreport\inputs\Bindable;
    use \koolreport\inputs\POSTBinding;
    use \koolreport\amazing\Theme;
    use \koolreport\export\Exportable;

    function settings()
    {
        return [
            "dataSources" => [
                "kinder" => [
                    "connectionString" => "mysql:host=" . $_SESSION['db_host'] . ";dbname=" . $_SESSION['db_name'],
                    "username"         => $_SESSION['db_user'],
                    "password"         => $_SESSION['db_pass'],
                    "charset"          => "utf8"
                ]
            ],
            "subReports" => [
                "maintable" => MainTable::class,
                "subtable"  => SubTable::class,
            ]
        ];
    }

    protected function setup(){
        $this->src('kinder')
        ->query(sessionLocationsQuery())
        ->pipe($this->dataStore('locationDataStore'));

    }
}

Right now the export only exports the MainTable. I would like it to export the Subtable instead. Is this possible?

Thanks

G
George commented on Jun 14, 2022

Sorry solved by just referencing the correct table.

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

Export