ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilAssExcelFormatHelper Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilAssExcelFormatHelper:
+ Collaboration diagram for ilAssExcelFormatHelper:

Public Member Functions

 __construct ()
 ilAssExcelFormatHelper constructor. More...
 
 setFormattedExcelTitle ($coordinates, $value)
 
 setCellByCoordinates ($a_coords, $a_value)
 
 setCell ($a_row, $a_col, $a_value, $datatype=null)
 
 getStringEscaping ()
 
 setStringEscaping ($stringEscaping)
 
- Public Member Functions inherited from ilExcel
 __construct ()
 
 loadFromFile (string $filename)
 Loads a spreadsheet from file. More...
 
 getValidFormats ()
 
 setFormat (string $a_format)
 Set file format. More...
 
 addSheet (string $a_name, bool $a_activate=true)
 Add sheet. More...
 
 setActiveSheet (int $a_index)
 
 getSheetCount ()
 Returns number of sheets. More...
 
 getSheetTitle ()
 Return the current sheet title. More...
 
 setCellByCoordinates ($a_coords, $a_value)
 Set cell value by coordinates. More...
 
 setCell (int $a_row, int $a_col, $a_value, ?string $a_datatype=null)
 Set cell value. More...
 
 setCellArray (array $a_values, string $a_top_left='A1', $a_null_value=null)
 Set cell values from array. More...
 
 getCell (int $a_row, int $a_col)
 Returns the value of a cell. More...
 
 getSheetAsArray ()
 Returns the active sheet as an array. More...
 
 getColumnCount ()
 Returns the number of columns the sheet contains. More...
 
 getColumnCoord (int $a_col)
 Get column "name" from number. More...
 
 sendToClient (string $a_file_name)
 Send workbook to client. More...
 
 writeToFile (string $a_file)
 Save workbook to file. More...
 
 writeToTmpFile ()
 
 setBold (string $a_coords)
 Set cell(s) to bold. More...
 
 setColors (string $a_coords, string $a_background, string $a_font=null)
 Set cell(s) colors. More...
 
 setBorders (string $a_coords, bool $a_top, bool $a_right=false, bool $a_bottom=false, bool $a_left=false)
 Toggle cell(s) borders. More...
 
 getCoordByColumnAndRow (int $pColumn=1, int $pRow=1)
 Get cell coordinate (e.g. More...
 
 addLink (int $a_row, int $a_column, string $a_path)
 
 columnIndexAdjustment (int $column)
 Adjustment needed because of migration PHPExcel to PhpSpreadsheet. More...
 
 mergeCells (string $coordinatesRange)
 

Data Fields

const escapeString = true
 
- Data Fields inherited from ilExcel
const FORMAT_XML = 'Xlsx'
 
const FORMAT_BIFF = 'Xls'
 

Protected Member Functions

 prepareString ($a_value)
 
- Protected Member Functions inherited from ilExcel
 prepareValue ($a_value)
 Prepare value for cell. More...
 
 prepareDateValue (ilDateTime $a_value)
 
 prepareBooleanValue (bool $a_value)
 
 prepareString (string $a_value)
 
 setDateFormat (Cell $a_cell, $a_value)
 Set date format of cell. More...
 
 setGlobalAutoSize ()
 Set all existing columns on all sheets to autosize. More...
 
 prepareStorage (string $a_file_name)
 Prepare workbook for storage/delivery. More...
 

Protected Attributes

 $stringEscaping = self::escapeString
 
- Protected Attributes inherited from ilExcel
string $format
 
ilLanguage $lng
 
Spreadsheet $workbook
 
string $type
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilAssExcelFormatHelper

Author
Guido Vollbach gvoll.nosp@m.bach.nosp@m.@data.nosp@m.bay..nosp@m.de

Definition at line 25 of file class.ilAssExcelFormatHelper.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssExcelFormatHelper::__construct ( )

ilAssExcelFormatHelper constructor.

Definition at line 34 of file class.ilAssExcelFormatHelper.php.

References ILIAS\MetaData\Repository\Validation\Data\__construct().

35  {
37  }
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ getStringEscaping()

ilAssExcelFormatHelper::getStringEscaping ( )
Returns
int

Definition at line 99 of file class.ilAssExcelFormatHelper.php.

References $stringEscaping.

Referenced by assTextQuestion\setExportDetailsXLSX(), and assClozeTest\setExportDetailsXLSX().

+ Here is the caller graph for this function:

◆ prepareString()

ilAssExcelFormatHelper::prepareString (   $a_value)
protected
Parameters
string$a_value
Returns
string

Definition at line 87 of file class.ilAssExcelFormatHelper.php.

87  : string
88  {
89  if ($this->stringEscaping == false) {
90  return $a_value;
91  } else {
92  return strip_tags($a_value);
93  }
94  }

◆ setCell()

ilAssExcelFormatHelper::setCell (   $a_row,
  $a_col,
  $a_value,
  $datatype = null 
)

Definition at line 69 of file class.ilAssExcelFormatHelper.php.

References ilExcel\getCoordByColumnAndRow(), and ilExcel\prepareValue().

Referenced by assOrderingHorizontal\setExportDetailsXLSX(), assErrorText\setExportDetailsXLSX(), assNumeric\setExportDetailsXLSX(), assTextSubset\setExportDetailsXLSX(), assTextQuestion\setExportDetailsXLSX(), assLongMenu\setExportDetailsXLSX(), assImagemapQuestion\setExportDetailsXLSX(), assFileUpload\setExportDetailsXLSX(), assKprimChoice\setExportDetailsXLSX(), assMultipleChoice\setExportDetailsXLSX(), assSingleChoice\setExportDetailsXLSX(), assOrderingQuestion\setExportDetailsXLSX(), assMatchingQuestion\setExportDetailsXLSX(), assFormulaQuestion\setExportDetailsXLSX(), and assClozeTest\setExportDetailsXLSX().

69  : void
70  {
71  if (is_string($a_value) && !is_numeric($a_value)) {
72  $coordinate = $this->getCoordByColumnAndRow($a_col, $a_row);
73  $this->workbook->getActiveSheet()->setCellValueExplicit(
74  $coordinate,
75  $this->prepareValue($a_value),
76  \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING
77  );
78  } else {
79  parent::setCell($a_row, $a_col, $a_value);
80  }
81  }
getCoordByColumnAndRow(int $pColumn=1, int $pRow=1)
Get cell coordinate (e.g.
prepareValue($a_value)
Prepare value for cell.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCellByCoordinates()

ilAssExcelFormatHelper::setCellByCoordinates (   $a_coords,
  $a_value 
)

Definition at line 53 of file class.ilAssExcelFormatHelper.php.

References ilExcel\prepareValue().

Referenced by setFormattedExcelTitle().

53  : 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  );
61  } else {
62  parent::setCellByCoordinates($a_coords, $a_value);
63  }
64  }
prepareValue($a_value)
Prepare value for cell.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFormattedExcelTitle()

ilAssExcelFormatHelper::setFormattedExcelTitle (   $coordinates,
  $value 
)
Parameters
string$coordinates
string$value

Definition at line 43 of file class.ilAssExcelFormatHelper.php.

References EXCEL_BACKGROUND_COLOR, ilExcel\setBold(), setCellByCoordinates(), and ilExcel\setColors().

Referenced by assQuestion\setExportDetailsXLSX().

43  : void
44  {
45  $this->setCellByCoordinates($coordinates, $value);
46  $this->setColors($coordinates, EXCEL_BACKGROUND_COLOR);
47  $this->setBold($coordinates);
48  }
const EXCEL_BACKGROUND_COLOR
setBold(string $a_coords)
Set cell(s) to bold.
setCellByCoordinates($a_coords, $a_value)
setColors(string $a_coords, string $a_background, string $a_font=null)
Set cell(s) colors.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStringEscaping()

ilAssExcelFormatHelper::setStringEscaping (   $stringEscaping)
Parameters
int$stringEscaping

Definition at line 107 of file class.ilAssExcelFormatHelper.php.

References $stringEscaping.

Referenced by assTextQuestion\setExportDetailsXLSX(), and assClozeTest\setExportDetailsXLSX().

107  : void
108  {
109  $this->stringEscaping = $stringEscaping;
110  }
+ Here is the caller graph for this function:

Field Documentation

◆ $stringEscaping

ilAssExcelFormatHelper::$stringEscaping = self::escapeString
protected

Definition at line 29 of file class.ilAssExcelFormatHelper.php.

Referenced by getStringEscaping(), and setStringEscaping().

◆ escapeString

const ilAssExcelFormatHelper::escapeString = true

Definition at line 27 of file class.ilAssExcelFormatHelper.php.


The documentation for this class was generated from the following file: