-
-
Save Zer0xFF/24e57a92e3f76eff78170a7c063c6e6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$conditions = []; | |
$conditions[] = [\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS, \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_EQUAL, '="NA"', "FFFFC7CE"]; | |
$conditions[] = [\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT, \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_CONTAINSTEXT, "+", "FFfae900"]; | |
$conditions[] = [\PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CONTAINSTEXT, \PhpOffice\PhpSpreadsheet\Style\Conditional::OPERATOR_CONTAINSTEXT, "-", "FFfae900"]; | |
foreach(['E:E','H:H', 'I:I'] as $column) | |
{ | |
$conditionalStyles = $active_sheet->getStyle($column)->getConditionalStyles(); | |
foreach($conditions as $condition) | |
{ | |
// dd($condition, $column); | |
list($con, $op, $val, $color) = $condition; | |
$conditional1 = new \PhpOffice\PhpSpreadsheet\Style\Conditional(); | |
$conditional1->setConditionType($con); | |
$conditional1->setOperatorType($op); | |
if($con != \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) | |
{ | |
$conditional1->setText($val); | |
} | |
else | |
{ | |
$conditional1->addCondition($val); | |
} | |
$conditional1->getStyle()->applyFromArray( | |
[ | |
'fill' => | |
[ | |
'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, | |
'color' => ['argb' => $color], | |
], | |
] | |
); | |
$conditionalStyles[] = $conditional1; | |
} | |
$active_sheet->getStyle($column)->setConditionalStyles($conditionalStyles); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment