KoolReport's Forum

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

Export from Single Page Report #1618

Open The O opened this topic on on Sep 15, 2020 - 1 comments

The O commented on Sep 15, 2020

I keep getting this error:

Fatal error: Call to a member function export() on null in... 

My single page class starts like this:

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\instant\SinglePage;
	use \koolreport\bootstrap4\Theme;
	use \koolreport\export\Export;
	

called thus:

php $report->end()->export()->pdf(array(
    "format"=>"A4",
    "orientation"=>"portrait"
))->toBrowser("myfile.pdf");

I notice there is no export.php in the export folder, rather Exportable.php.

How do I make it work? I have phantomjs dropped in a created bin folder under export.

David Winterburn commented on Sep 16, 2020

With single page report, you can't use export() command on itself because the report output its content right when you include the report class. Instead, please use class \koolreport\instant\Exporter to export the single page one like this:

//SinglePageReport.php
...
<button type="submit" formaction="path/to/export.php">Export to PDF</button>


//export.php
    use \koolreport\instant\Exporter;
    Exporter::export("path/to/SinglePageReport.php")
    ->pdf(array(
        "format"=>"A4",
        "orientation"=>"portrait"
    ))
    ->toBrowser("SinglePageReport.pdf");

Hope it works for you. Let us know otherwise. Thanks!

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

None