ILIAS  release_8 Revision v8.24
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)
 Set cell value by coordinates.
Parameters
string$a_coordsCoordinate of the cell, eg: 'A1'
mixed$a_value
More...
 
 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 ()
 Get valid file formats. More...
 
 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.

Reimplemented from ilExcel.

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

35 {
37 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getStringEscaping()

ilAssExcelFormatHelper::getStringEscaping ( )
Returns
int

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

References $stringEscaping.

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

+ Here is the caller graph for this function:

◆ prepareString()

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

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

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

◆ setCell()

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

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

70 : 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 }
prepareValue($a_value)
Prepare value for cell.

References ilExcel\prepareValue().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCellByCoordinates()

ilAssExcelFormatHelper::setCellByCoordinates (   $a_coords,
  $a_value 
)

Set cell value by coordinates.

Parameters
string$a_coordsCoordinate of the cell, eg: 'A1'
mixed$a_value

Reimplemented from ilExcel.

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

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 true
61 );
62 } else {
63 parent::setCellByCoordinates($a_coords, $a_value);
64 }
65 }

References ilExcel\prepareValue().

Referenced by setFormattedExcelTitle().

+ 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.

43 : void
44 {
45 $this->setCellByCoordinates($coordinates, $value);
46 $this->setColors($coordinates, EXCEL_BACKGROUND_COLOR);
47 $this->setBold($coordinates);
48 }
setCellByCoordinates($a_coords, $a_value)
Set cell value by coordinates.
setBold(string $a_coords)
Set cell(s) to bold.
setColors(string $a_coords, string $a_background, string $a_font=null)
Set cell(s) colors.
const EXCEL_BACKGROUND_COLOR

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

Referenced by assQuestion\setExportDetailsXLS().

+ 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 109 of file class.ilAssExcelFormatHelper.php.

109 : void
110 {
111 $this->stringEscaping = $stringEscaping;
112 }

References $stringEscaping.

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

+ 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: