ILIAS  release_8 Revision v8.24
class.ilAssExcelFormatHelper.php
Go to the documentation of this file.
1<?php
2
19require_once 'Modules/Test/classes/inc.AssessmentConstants.php';
20
26{
27 public const escapeString = true;
28
30
34 public function __construct()
35 {
37 }
38
43 public function setFormattedExcelTitle($coordinates, $value): void
44 {
45 $this->setCellByCoordinates($coordinates, $value);
46 $this->setColors($coordinates, EXCEL_BACKGROUND_COLOR);
47 $this->setBold($coordinates);
48 }
49
53 public function setCellByCoordinates($a_coords, $a_value): void
54 {
55 if (is_string($a_value) && !is_numeric($a_value)) {
56 $this->workbook->getActiveSheet()->setCellValueExplicit(
57 $a_coords,
58 $this->prepareValue($a_value),
59 \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING,
60 true
61 );
62 } else {
63 parent::setCellByCoordinates($a_coords, $a_value);
64 }
65 }
66
70 public function setCell($a_row, $a_col, $a_value, $datatype = null): void
71 {
72 if (is_string($a_value) && !is_numeric($a_value)) {
73 $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
74 $a_col + 1,
75 $a_row,
76 $this->prepareValue($a_value),
77 \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING,
78 true
79 );
80 } else {
81 parent::setCell($a_row, $a_col, $a_value);
82 }
83 }
84
89 protected function prepareString($a_value): string
90 {
91 if ($this->stringEscaping == false) {
92 return $a_value;
93 } else {
94 return strip_tags($a_value);
95 }
96 }
97
101 public function getStringEscaping()
102 {
104 }
105
109 public function setStringEscaping($stringEscaping): void
110 {
111 $this->stringEscaping = $stringEscaping;
112 }
113}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct()
ilAssExcelFormatHelper constructor.
setFormattedExcelTitle($coordinates, $value)
setCell($a_row, $a_col, $a_value, $datatype=null)
setCellByCoordinates($a_coords, $a_value)
Set cell value by coordinates.
setBold(string $a_coords)
Set cell(s) to bold.
prepareValue($a_value)
Prepare value for cell.
setColors(string $a_coords, string $a_background, string $a_font=null)
Set cell(s) colors.
const EXCEL_BACKGROUND_COLOR
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc