ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAssExcelFormatHelper.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3require_once 'Modules/Test/classes/inc.AssessmentConstants.php';
4require_once 'Services/Excel/classes/class.ilExcel.php';
5
11{
12 const escapeString = true;
13
15
19 public function __construct()
20 {
22 }
23
28 public function setFormattedExcelTitle($coordinates, $value)
29 {
30 $this->setCellByCoordinates($coordinates, $value);
31 $this->setColors($coordinates, EXCEL_BACKGROUND_COLOR);
32 $this->setBold($coordinates);
33 }
34
38 public function setCellByCoordinates($a_coords, $a_value)
39 {
40 if (is_string($a_value) && !is_numeric($a_value)) {
41 $this->workbook->getActiveSheet()->setCellValueExplicit(
42 $a_coords,
43 $this->prepareValue($a_value),
44 \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING,
45 true
46 );
47 } else {
48 parent::setCellByCoordinates($a_coords, $a_value);
49 }
50 }
51
55 public function setCell($a_row, $a_col, $a_value, $datatype=null)
56 {
57 if (is_string($a_value) && !is_numeric($a_value)) {
58 $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
59 $a_col + 1,
60 $a_row,
61 $this->prepareValue($a_value),
62 \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING,
63 true
64 );
65 } else {
66 parent::setCell($a_row, $a_col, $a_value);
67 }
68 }
69
74 protected function prepareString($a_value)
75 {
76 if ($this->stringEscaping == false) {
77 return $a_value;
78 } else {
79 return strip_tags($a_value);
80 }
81 }
82
86 public function getStringEscaping()
87 {
89 }
90
95 {
96 $this->stringEscaping = $stringEscaping;
97 }
98}
An exception for terminatinating execution or to throw for unit testing.
Class ilAssExcelFormatHelper.
__construct()
ilAssExcelFormatHelper constructor.
setFormattedExcelTitle($coordinates, $value)
setCell($a_row, $a_col, $a_value, $datatype=null)
Set cell value.PhpOffice\PhpSpreadsheet\Exception
setCellByCoordinates($a_coords, $a_value)
Set cell value by coordinates.
prepareValue($a_value)
Prepare value for cell.
setColors($a_coords, $a_background, $a_font=null)
Set cell(s) colors.
setBold($a_coords)
Set cell(s) to bold.
const EXCEL_BACKGROUND_COLOR
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc