Below is the code, the datasource is from array which I pass as parameter;
// MyReport.php
public function settings()
{
return array(
"dataSources" => array(
"data" => array(
"class" => '\koolreport\datasources\ArrayDataSource',
"data" => $this->params["report"],
"dataFormat" => "associate",
)
)
);
}
function setup()
{
$this->src('data')
->pipe($this->dataStore("result"));
}
}
The excel view is as follows:
// MyReportExcel.view.php
<?php
use koolreport\excel\Table;
use koolreport\excel\PieChart;
$sheet1 = "Something Title Title";
$title = "statistics";
?>
<meta charset="UTF-8">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="Excel,HTML,CSS,XML,JavaScript">
<meta name="creator" content="John Doe">
<meta name="subject" content="subject1">
<meta name="title" content="title1">
<meta name="category" content="category1">
<div sheet-name="<?php echo $title; ?>">
<div><?php echo $sheet1; ?></div>
<div>
<?php
Table::create(array(
"dataSource" => 'result',
));
?>
</div>
</div>
I managed to export to excel, however the table is empty but the columns are printed out. I have tried to print the datastore using json_encode($this->dataStore('result')->data()); and it managed to print out the data just fine.