Hi David,
Here is the code :
<?php // MyReportExcel.view.php
use \koolreport\pivot\widgets\PivotTable;
use \koolreport\widgets\koolphp\Table;
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
?>
<?php
$styleArray = [
'font' => [
'name' => 'Calibri', //'Verdana', 'Arial'
'size' => 30,
'bold' => false,
'italic' => FALSE,
'underline' => 'none', //'double', 'doubleAccounting', 'single', 'singleAccounting'
'strikethrough' => FALSE,
'superscript' => false,
'subscript' => false,
'color' => [
'rgb' => '000000',
'argb' => 'FF000000',
]
],
'alignment' => [
'horizontal' => 'general',//left, right, center, centerContinuous, justify, fill, distributed
'vertical' => 'bottom',//top, center, justify, distributed
'textRotation' => 0,
'wrapText' => false,
'shrinkToFit' => false,
'indent' => 0,
'readOrder' => 0,
],
'borders' => [
'top' => [
'borderStyle' => 'none', //dashDot, dashDotDot, dashed, dotted, double, hair, medium, mediumDashDot, mediumDashDotDot, mediumDashed, slantDashDot, thick, thin
'color' => [
'rgb' => '808080',
'argb' => 'FF808080',
]
],
//left, right, bottom, diagonal, allBorders, outline, inside, vertical, horizontal
],
'fill' => [
'fillType' => 'none', //'solid', 'linear', 'path', 'darkDown', 'darkGray', 'darkGrid', 'darkHorizontal', 'darkTrellis', 'darkUp', 'darkVertical', 'gray0625', 'gray125', 'lightDown', 'lightGray', 'lightGrid', 'lightHorizontal', 'lightTrellis', 'lightUp', 'lightVertical', 'mediumGray'
'rotation' => 90,
'color' => [
'rgb' => 'A0A0A0',
'argb' => 'FFA0A0A0',
],
'startColor' => [
'rgb' => 'A0A0A0',
'argb' => 'FFA0A0A0',
],
'endColor' => [
'argb' => 'FFFFFF',
'argb' => 'FFFFFFFF',
],
],
];
?>
<div cell="A1" range="A1:H1" excelstyle='<?php echo json_encode($styleArray); ?>' >
Custom Report
</div>
<div>Orders</div>
<div>
<?php
Table::create(array(
"dataSource" => $this->dataStore('table'),
// "dataSource" => 'orders',
"headersExcelStyle" => [
'customerName' => [
'font' => [
'italic' => true,
'color' => [
'rgb' => '808080',
]
],
]
],
"columnsExcelStyle" => [
'customerName' => [
'font' => [
'italic' => true,
'color' => [
'rgb' => '808080',
]
],
]
],
));
?>
</div>
<?php
$datastore = 'table';
$title = 'Test Records';
$name = 'Test Records';
$column = 'test';
?>
<div>
<?php echo $title; ?>
</div>
<div>
<?php
Table::create(array(
"name" => $name,
"dataSource" => $this->dataStore($datastore),
// "dataSource" => $datastore,
"columns" =>[
$column, "Q1", "Q2", "Q3"
],
));
?>
</div>
<?php
?>
</div>
I think it will also help. Here is code of Myreport.php from where I get the view of first page.
<?php
require_once "../vendor/koolreport/core/autoload.php";
include realpath(dirname(__FILE__)."/../").'/includes/master_header.php'; // Website header
include realpath(dirname(__FILE__)."/").'/common_connection.php'; //database connection file
class MyReport extends \koolreport\KoolReport
{
use \koolreport\export\Exportable;
use \koolreport\excel\ExcelExportable;
use \koolreport\clients\Bootstrap;
public function settings()
{
$common_connection = new common_connection(); // Separated out connection for common use of multiple view
return $common_connection->connection();
}
function setup()
{
$qry = "SELECT col1,col2,col3 FROM table ORDER BY `col1` ASC limit 0,11"; //This is not original query
$report_qry = $this->src('database');
$report_qry->query($qry);
$report_qry->pipe($this->dataStore('table'));
}
}
And MyReport.view.php
<?php
use \koolreport\pivot\widgets\PivotTable;
use \koolreport\widgets\koolphp\Table;
$get_heading = ["col1","col2","col3"];
?>
<div sheet-name="Sheet">
<style>
.page-header {
margin: 0;
}
</style>
<div class="report-content">
<div style='text-align: center;margin-bottom:30px;'>
<h1>Excel Exporting Template</h1>
<p class="lead">Using template to create excel report</p>
<form>
<button type="submit" class="btn btn-primary" formaction="export.php">Download Excel</button>
</form>
</div>
<div class='box-container'>
<div>
<?php
$columns = array();
$data_field = $this->dataStore('table')->data();
$i=0;
foreach($data_field[0] as $key=>$value)
{
$columns[$key] = array(
"label" => $get_heading[$i],
);
$i++;
}
Table::create(array(
"dataStore"=>$this->dataStore('table'),
"columns" => $columns,
"paging"=>array(
"pageSize"=>10,
),
// "showHeader"=>false,
"cssClass"=>array(
"table"=>"table table table-bordered table-striped",
)
));
?>
</div>
</div>
</div>
Can you help me out to know what I'm doing wrong?
Thanks