ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 */
3 require_once 'Modules/Test/classes/inc.AssessmentConstants.php';
4 require_once 'Services/Excel/classes/class.ilExcel.php';
5 
11 {
12 
13  const escapeString = true;
14 
15  protected $stringEscaping = self::escapeString;
16 
20  public function __construct()
21  {
22  parent::__construct();
23  }
24 
29  public function setFormattedExcelTitle($coordinates, $value)
30  {
31  $this->setCellByCoordinates($coordinates, $value);
32  $this->setColors($coordinates, EXCEL_BACKGROUND_COLOR);
33  $this->setBold($coordinates);
34  }
35 
39  public function setCellByCoordinates($a_coords, $a_value)
40  {
41  if(is_string($a_value) && !is_numeric($a_value))
42  {
43  $this->workbook->getActiveSheet()->setCellValueExplicit(
44  $a_coords,
45  $this->prepareValue($a_value),
47  true
48  );
49  }
50  else
51  {
52  parent::setCellByCoordinates($a_coords, $a_value);
53  }
54  }
55 
59  public function setCell($a_row, $a_col, $a_value)
60  {
61  if(is_string($a_value) && !is_numeric($a_value))
62  {
63  $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
64  $a_col,
65  $a_row,
66  $this->prepareValue($a_value),
68  true
69  );
70  }
71  else
72  {
73  parent::setCell($a_row, $a_col, $a_value);
74  }
75  }
76 
81  protected function prepareString($a_value)
82  {
83  if($this->stringEscaping == false)
84  {
85  return $a_value;
86  }
87  else
88  {
89  return strip_tags($a_value);
90  }
91  }
92 
96  public function getStringEscaping()
97  {
98  return $this->stringEscaping;
99  }
100 
105  {
106  $this->stringEscaping = $stringEscaping;
107  }
108 }
const EXCEL_BACKGROUND_COLOR
Add a hyperlink to another cell on a different worksheet within the workbook
setBold($a_coords)
Set cell(s) to bold.
__construct()
ilAssExcelFormatHelper constructor.
setCellByCoordinates($a_coords, $a_value)
setColors($a_coords, $a_background, $a_font=null)
Set cell(s) colors.
setFormattedExcelTitle($coordinates, $value)
Class ilAssExcelFormatHelper.
setCell($a_row, $a_col, $a_value)
prepareValue($a_value)
Prepare value for cell.