KoolReport's Forum

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

Export with dashboard without ChromeHeadlessio #2544

Open Javier Gallardo opened this topic on on Jan 24, 2022 - 36 comments

Javier Gallardo commented on Jan 24, 2022

I need an example to be able to export html tables, texts and graphics with dashboard but without using ChromeHeadlessio

Sebastian Morales commented on Jan 25, 2022

You could set up local export in your App.php like this:

class App extends \koolreport\dashboard\Application
{
    ...
    protected function export()
    {
        return ExportHandler::create()
                ->storage(dirname(__DIR__)."/storage")
                ->csvEngine(
                    CSVEngine::create()
                )
                ->xlsxEngine(
                    XLSXEngine::create()
                )
                ->pdfEngine(
                    \koolreport\dashboard\export\LocalExport::create()
                );                
    }
} 
Javier Gallardo commented on Jan 25, 2022

how could i add export button in report.view.php

Javier Gallardo commented on Jan 25, 2022

the example they have is too basic, they have some example with dasboard, src folder, file report.php reportBoard.php reportBoar.View.php

KoolReport commented on Jan 26, 2022

May I know your application is built using KoolReport Pro or Dashboard Framework. Our above example is for Dashboard Framework which does not need the view files like reportBoard.php and reportBoard.view.php like using KoolReport Pro.

Javier Gallardo commented on Jan 26, 2022

pro

KoolReport commented on Jan 26, 2022

Please download phantomjs following instruction here. And here is the example of using export package:

https://www.koolreport.com/examples/reports/export/sakila_rental/

Let us know if you need further assistance.

Javier Gallardo commented on Feb 2, 2022

I need example with dashboard!!

when i add this in my class

class MyReport extends \koolreport\KoolReport {

use \koolreport\export\Exportable;
...

} I have this error

I think it happens because I have in the class Orderlist a function that uses the data of the logged in user and it is not compatible with extends koolreport/koolreport

static function settings($user)

{

)

I use that class to show the data of the logged in user my class has functions that use in report.view.php

Sebastian Morales commented on Feb 7, 2022

This error has nothing to do with export. You just can not call OrderList::settings(...) because settings is not a static method of class OrderList. What were you trying to do here?

Javier Gallardo commented on Feb 7, 2022

I can't use use \koolreport\export\Exportable; because my class use it to obtain the data of the logged in user

Sebastian Morales commented on Feb 8, 2022

Pls use another static method name other than settings($user) because KoolReport class already has its predefined settings method. You call call it static function getDataFromUser($user) {...}.

Javier Gallardo commented on Feb 10, 2022

I changed the names but now it can't find the folder, do you have any idea why?

Fatal error: Uncaught Error: Class 'koolreport\KoolReport' not found in \htdocs\src\report\Report.php:16 Stack trace: #0 C:\xampp\htdocs\src\report\export.php(2): require_once() #1 {main} thrown in C:\xampp\htdocs\src\report\Report.php on line 16

Sebastian Morales commented on Feb 11, 2022

Pls add another require_once "path/to/koolreport/core/autoload.php" or "path/to/vendor/autoload.php" (even if you added one before) to the beginning of your Report.php page. Rgds,

Javier Gallardo commented on Feb 14, 2022

where should I add that, inside the class? in what line

Javier Gallardo commented on Feb 15, 2022

???????????????????????????????????????

KoolReport commented on Feb 15, 2022

It should be on top of your class:

<?php

require_once "path/to/koolreport/core/autoload.php"; // Please change the path correctly.

namespace space;

...
Javier Gallardo commented on Feb 15, 2022

Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in C:\xampp\htdocs\src\report\Report.php on line 4

I think it cannot be put above the namespace, that is the only error that does not allow me to create the pdf

Javier Gallardo commented on Feb 15, 2022

not having an example, I waste too much time here, I suggest you make an example in the documentation

KoolReport commented on Feb 15, 2022

Then you put the require_once after namespace. It is also fine.

Javier Gallardo commented on Feb 15, 2022

Do I need index.php or is the one already in the dashboard enough?

KoolReport commented on Feb 15, 2022

The OrderList.php contains the OrderList report class only, you need the code in index.php to create object from class and render the report. So you need the index.php or exactly the code inside index.php.

Javier Gallardo commented on Feb 16, 2022

when I put the require I get the following error

Fatal error: koolreport\KoolReport::main(): Failed opening required 'htdocs/vendor/koolreport/coreautoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\src\report\Report.php on line 5

Javier Gallardo commented on Feb 16, 2022

when I use include instead of require

Message: include_once(C:\xampp\htdocs\src\reportC: mpp\htdocs endor\koolreport\core\autoload.php): failed to open stream: No such file or directory Line: 5

Sebastian Morales commented on Feb 16, 2022

The path should be "htdocs/vendor/koolreport/core/autoload.php". It's core/autoload.php, not coreautoload.php.

KoolReport commented on Feb 16, 2022

Please make sure you have correct path, whether you use relative path or absolute path. More information of require_once, you can find here.

Javier Gallardo commented on Feb 17, 2022

Fatal error: Uncaught Error: Class 'OrderList' not found in C:\xampp\htdocs\src\report\export.php:3

KoolReport commented on Feb 17, 2022

What is the name of the file that contains OrderList class?

Javier Gallardo commented on Feb 17, 2022

when i add namespace i get following error

Fatal error: Uncaught Exception: Could not save content to temporary folder in C:\xampp\htdocs\vendor\koolreport\export\Handler.php:138 Stack trace: #0 C:\xampp\htdocs\vendor\koolreport\export\Handler.php(265): koolreport\export\Handler->saveTempContent() #1 C:\xampp\htdocs\src\report\export.php(13): koolreport\export\Handler->pdf(Array) #2 {main} thrown in C:\xampp\htdocs\vendor\koolreport\export\Handler.php on line 138

Javier Gallardo commented on Feb 17, 2022

the file containing the OrderList class is Report.php

KoolReport commented on Feb 17, 2022

Since you use the namespace then you need to do this:

$report = new \space\OrderList;

instead of just

$report = new OrderList;
Javier Gallardo commented on Feb 17, 2022

Fatal error: Uncaught Exception: Could not save content to temporary folder in C:\xampp\htdocs\vendor\koolreport\export\Handler.php:138 Stack trace: #0 C:\xampp\htdocs\vendor\koolreport\export\Handler.php(265): koolreport\export\Handler->saveTempContent() #1 C:\xampp\htdocs\src\report\export.php(13): koolreport\export\Handler->pdf(Array) #2 {main} thrown in C:\xampp\htdocs\vendor\koolreport\export\Handler.php on line 138

KoolReport commented on Feb 18, 2022

Normally PHP is able to save file into temporary folder, it could be "/var/tmp" (/tmp) in linux or "C:\Users

echo sys_get_temp_dir();

It could be that your php settings is not assigned temp folder, please change it in your php.ini settings file and reset server and php.

Second option, please try to turn on "useLocalTempFolder"=>true.

Let me know if it works.

Javier Gallardo commented on Feb 18, 2022

where should i write that?

"useLocalTempFolder"=>true

KoolReport commented on Feb 18, 2022

Do you see in here:

$report->run()
->export("ReportBoard.view")
->settings([
    "useLocalTempFolder"=>true
])

By the way it seems to me ->export("ReportBoard.view") is not correct. If you have the ReportBoard.view.php then you should do ->export("ReportBoard") only (omit the .view.php)

Javier Gallardo commented on Feb 18, 2022

Fatal error: Uncaught Exception: Could not find phantomjs executed file in bin folder in C:\xampp\htdocs\vendor\koolreport\export\Handler.php:55 Stack trace: #0 C:\xampp\htdocs\vendor\koolreport\export\Handler.php(274): koolreport\export\Handler->runPhantom('C:\xampp\htdocs...', 'C:\xampp\htdocs...', 'C:\xampp\htdocs...', 'eyJmb3JtYXQiOiJ...') #1 C:\xampp\htdocs\src\report\export.php(13): koolreport\export\Handler->pdf(Array) #2 {main} thrown in C:\xampp\htdocs\vendor\koolreport\export\Handler.php on line 55

KoolReport commented on Feb 18, 2022

Oh, there is instruction in our export installation page. it needs phantomjs Here is come. Please download correct version of phantomjs for your system. And set the execution permission for the file.

Javier Gallardo commented on Feb 18, 2022

it works but don't close it yet because I have some details to review

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

None