Skip to content

Instantly share code, notes, and snippets.

@Zer0xFF

Zer0xFF/test.php Secret

Created Jul 7, 2021
Embed
What would you like to do?
<?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