You are here

protected function Xls::setConditionalFormat in Excel Serialization 8

Gets conditional formatting for whole row if the comparison is TRUE.

Parameters

string $column_letter: The column letter that contains the cells to compare against.

string $operator: The operator to use in the comparison.

string $compare_to: The value to compare to.

string $rgb_background_color: The RGB value of the background color to set on the whole row, if the comparison is TRUE.

Return value

\PhpOffice\PhpSpreadsheet\Style\Conditional The conditional formatting.

1 call to Xls::setConditionalFormat()
Xls::encode in src/Encoder/Xls.php
Encodes data into the given format.

File

src/Encoder/Xls.php, line 412

Class

Xls
Adds XLS encoder support for the Serialization API.

Namespace

Drupal\xls_serialization\Encoder

Code

protected function setConditionalFormat($column_letter, $operator, $compare_to, $rgb_background_color) {
  $conditional_format = new Conditional();
  $conditional_format
    ->setConditionType(Conditional::CONDITION_EXPRESSION);
  $conditional_format
    ->addCondition('=$' . $column_letter . '2' . $operator . '"' . $compare_to . '"');
  $conditional_format
    ->getStyle()
    ->getFill()
    ->setFillType(Fill::FILL_SOLID)
    ->getEndColor()
    ->setRGB($rgb_background_color);
  return $conditional_format;
}