File: D:/HostingSpaces/SBogers10/hours.komma.pro/app/Komma/Excel/ExcelExportOptions.php
<?php
namespace App\Komma\Excel;
class ExcelExportOptions
{
/**
* @param $data
* @param $sheet
*/
public function coloredRows($coloredRows, $sheet)
{
//loop through each row that must be colored
foreach ($coloredRows as $coloredRow) {
//make rows colored
$sheet->row($coloredRow, function ($row) {
$row->setFontColor('#ff0000');
});
}
}
/**
* @param $data
* @param $sheet
*/
public function boldRows($data, $sheet)
{
//loop through each row that must be bold
foreach ($data->specialRows->getBoldRowsHours as $getBoldRows) {
//make rows bold
$sheet->row($getBoldRows, function ($row) {
$row->setFontWeight('bold');
});
}
}
/**
* @param $data
* @param $sheet
* @param $columnTotal
* @param $columnTitle
* @param $isProject
*/
public function subTotalRows($data, $sheet, $columnTotal, $columnTitle, $isProject)
{
//create empty array
$getNumberOfSubproject = [];
//loop trough number of subprojects
foreach ($data->getNumberOfSubproject as $key => $value){
//remove all 0 in array
if ($value != 0) $getNumberOfSubproject[] = $value;
}
//loop through each row that must be sum
foreach ($data->specialRows->getSumRowsHours as $index => $getSumRows) {
//create begin and end column row
$begin = $getSumRows - $getNumberOfSubproject[$index];
$end = $getSumRows - 1;
//set value in column
$sheet->setCellValue($columnTitle . $getSumRows, 'Subtotaal');
//set sum value in column
$sheet->setCellValue($columnTotal . $getSumRows, '=SUM('.$columnTotal . $begin . ':'.$columnTotal . $end . ')');
//second column for sum only for project export
if (!empty($isProject))
{
//set sum value in column
$sheet->setCellValue('G' . $getSumRows, '=SUM(G' . $begin . ':G' . $end . ')');
}
}
}
/**
* @param $data
* @param $sheet
*/
public function totalRow($data, $sheet)
{
if (!empty($data->specialRows->getAllSum))
$sheet->rows(array(
array(''),
array('', '', '', '', 'Totaal', '=SUM(' . $data->specialRows->getAllSum . ')', '=SUM(' . $data->specialRows->getAllSumNotFac . ')')
));
}
}