KoolReport's Forum

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

Call to undefined method Report::exportToExcel() #515

Open LCR opened this topic on on Nov 7, 2018 - 1 comments

LCR commented on Nov 7, 2018

Hi,

I call :

require_once($file_class); $report=new Report(); $report->run()->exportToExcel(array( "dataStores" => array(

	"measures"=>.......,

)))->toBrowser($file_export);

Call to undefined method Report::exportToExcel()

And the file class below, Thanks for your help.

<?php

use \koolreport\processes\Filter; use \koolreport\processes\ColumnMeta; use \koolreport\pivot\processes\Pivot; use \koolreport\excel\ExcelExportable;

class Report extends koolreport\KoolReport {

function settings()
{
	

	return array(
		"dataSources"=>array(
			'mysource'=>array(
				'class'=>'\koolreport\datasources\CSVDataSource',
				'filePath'=> 'mycsv.csv',
				'fieldSeparator' => ';',
				 "sheetName"=>"CA PAR COMMERCIAL", 
				 "sheetIndex"=>0, 
			)
		)
	);
	
}
function test()
{
	die("heel");
}
function setup()
{
	

$this->src("mysource") ->pipe(new ColumnMeta(array(

  "Contract_month_cost"=>array(
	"type" => "number",
  ),
)))

->pipe(new Pivot(array( "dimensions"=>array("column" => "Invoice|year_period,Invoice|month_period","row" => "Salesman|lastname,Agency|name", ),

"aggregates"=>array('sum' => 'Invoice|price,Invoice|recur_amount') ))) ->pipe($this->dataStore("mysource"));

}
public function render($view=null,$return=false)
{
	if(is_file($view))
	{
		$content = "";
		if($this->fireEvent("OnBeforeRender"))
		{
			ob_start();
			$this->getResourceManager()->init();
			$GLOBALS["__ACTIVE_KOOLREPORT__"] = $this;
			
			include($view);
			$content = ob_get_clean();	
			//Adding resource to content
			if($this->fireEvent("OnBeforeResourceAttached"))
			{
				$this->getResourceManager()->process($content);
				$this->fireEvent("OnResourceAttached");
			}

			$this->fireEvent("OnRenderEnd",array("content"=>&$content));
			if($return)
			{
				return $content;
			}
			else
			{
				echo $content;
				
			}
		}
	}
	else
	{
		$this->debug();
	}
}

} ?>

David Winterburn commented on Nov 8, 2018

Hi LCR,

To use the exportToExcel method, please add this trait from Excel package:

class MyReport extends koolreport\KoolReport
{
    use \koolreport\excel\ExcelExportable;

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

Excel