Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Please try this in your excel export template and let us know the result:
//MyReportExcel.view.php
$emptyStyleArray = [];
$rightStyleArray = [
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT,
]
];
Table::create(array(
...
"excelStyle" => [
"header" => function($colName) {
return $emptyStyleArray;
},
"cell" => function($colName, $value, $row) {
if ($colName === 'My right alignment column')
return $rightStyleArray;
else
return $emptyStyleArray;
},
"footer" => function($colName, $footerValue) {
return $emptyStyleArray;
},
]
...
));
Here it is:
{
"name": "koolreport/excel",
"version":"7.0.0",
"description": "Allow KoolReport to connect to Excel and export to excel file",
"keywords": ["PHP","Reporting Tools","Data Report","Charts","Exporting","Microsoft Excel","XLS","Export to Excel"],
"homepage": "https://www.koolreport.com",
"type": "library",
"license": "https://www.koolreport.com/license#mit-license",
"require": {
"phpoffice/phpspreadsheet": "^1.6",
"box/spout": "^3.0"
}
}
thanks
I did just now, I downloaded the latest one from my licenses. Now I have
{
"name": "koolreport/excel",
"version":"7.1.1",
"description": "Allow KoolReport to connect to Excel and export to excel file",
"keywords": ["PHP","Reporting Tools","Data Report","Charts","Exporting","Microsoft Excel","XLS","Export to Excel"],
"homepage": "https://www.koolreport.com",
"type": "library",
"license": "https://www.koolreport.com/license#mit-license",
"require": {
"phpoffice/phpspreadsheet": "^1.6",
"box/spout": "^3.0"
}
}
but this didn't fix the problem :/
here is the code to review:
<!-- render table -->
<?php
$emptyStyleArray = [];
$rightStyleArray = [
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT,
]
];
Table::create(array(
"dataStore"=>$this->dataStore('Journal Vouchers Report'),
"cssClass"=>array(
"table"=>"table table-hover table-bordered table-striped"
),
"excelStyle" => [
"header" => function($colName) {
return $rightStyleArray;
},
"cell" => function($colName, $value, $row) {
return $rightStyleArray;
},
"footer" => function($colName, $footerValue) {
return $rightStyleArray;
},
]
));
?>
I forgot the "use" keyword to use an outside variable in a function. Please try this and let us know the result:
<!-- render table -->
<?php
$emptyStyleArray = [];
$rightStyleArray = [
'alignment' => [
'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_RIGHT,
]
];
Table::create(array(
"dataStore"=>$this->dataStore('Journal Vouchers Report'),
"cssClass"=>array(
"table"=>"table table-hover table-bordered table-striped"
),
"excelStyle" => [
"header" => function($colName) use ($rightStyleArray) {
return $rightStyleArray;
},
"cell" => function($colName, $value, $row) use ($rightStyleArray) {
return $rightStyleArray;
},
"footer" => function($colName, $footerValue) use ($rightStyleArray) {
return $rightStyleArray;
},
]
));
?>
Thanks!
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo