ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilExcel Class Reference
+ Collaboration diagram for ilExcel:

Public Member Functions

 __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 $col, $value, ?string $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 FORMAT_XML = 'Xlsx'
 
const FORMAT_BIFF = 'Xls'
 

Protected Member Functions

 prepareValue ($value)
 Prepare value for cell. More...
 
 prepareDateValue (ilDateTime $a_value)
 
 prepareBooleanValue (bool $a_value)
 
 prepareString (string $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

string $format
 
ilLanguage $lng
 
Spreadsheet $workbook
 
string $type
 

Private Member Functions

 cleanupNonCharachters (string $string)
 

Private Attributes

array $noncharacters
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilExcel::__construct ( )
Exceptions

PhpOffice\PhpSpreadsheet\Exception

Definition at line 68 of file class.ilExcel.php.

69 {
70 global $DIC;
71
72 $this->lng = $DIC->language();
73 $this->setFormat(self::FORMAT_XML);
74 $this->workbook = new Spreadsheet();
75 $this->workbook->removeSheetByIndex(0);
76 }
setFormat(string $a_format)
Set file format.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\lng(), and setFormat().

+ Here is the call graph for this function:

Member Function Documentation

◆ addLink()

ilExcel::addLink ( int  $a_row,
int  $a_column,
string  $a_path 
)
Exceptions

PhpOffice\PhpSpreadsheet\Exception

Definition at line 565 of file class.ilExcel.php.

569 : void {
570 $coordinate = $this->getCoordByColumnAndRow($a_column, $a_row);
571 $this->workbook->getActiveSheet()->getCell($coordinate)->getHyperlink()->setUrl($a_path);
572 }
getCoordByColumnAndRow(int $pColumn=1, int $pRow=1)
Get cell coordinate (e.g.

◆ addSheet()

ilExcel::addSheet ( string  $a_name,
bool  $a_activate = true 
)

Add sheet.

Exceptions

PhpOffice\PhpSpreadsheet\Exception

Definition at line 122 of file class.ilExcel.php.

125 : int {
126 #20749
127 // see Worksheet::$_invalidCharacters;
128 $invalid = ['*', ':', '/', '\\', '?', '[', ']', '\'-', '\''];
129
130 $a_name = str_replace($invalid, '', $a_name);
131
132 // #19056 - phpExcel only allows 31 chars
133 // see https://github.com/PHPOffice/PHPExcel/issues/79
134 $a_name = ilStr::shortenTextExtended($a_name, 31);
135
136 $sheet = new Worksheet($this->workbook, $a_name);
137 $this->workbook->addSheet($sheet);
138 $new_index = $this->workbook->getSheetCount() - 1;
139
140 if ($a_activate) {
141 $this->setActiveSheet($new_index);
142 }
143
144 return $new_index;
145 }
setActiveSheet(int $a_index)
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)

◆ cleanupNonCharachters()

ilExcel::cleanupNonCharachters ( string  $string)
private

Definition at line 592 of file class.ilExcel.php.

592 : string
593 {
594 return mb_ereg_replace('[' . implode('', $this->noncharacters) . ']', '', $string);
595 }

◆ columnIndexAdjustment()

ilExcel::columnIndexAdjustment ( int  $column)

Adjustment needed because of migration PHPExcel to PhpSpreadsheet.

PhpExcel column was 0 index based and PhpSpreadshet set this index to 1

Definition at line 578 of file class.ilExcel.php.

578 : int
579 {
580 return ++$column;
581 }

◆ getCell()

ilExcel::getCell ( int  $a_row,
int  $a_col 
)

Returns the value of a cell.

Returns
mixed

Definition at line 359 of file class.ilExcel.php.

362 {
363 $coordinate = $this->getCoordByColumnAndRow($a_col, $a_row);
364 return $this->workbook->getActiveSheet()->getCell($coordinate)->getValue();
365 }

Referenced by ilDclBaseRecordFieldModel\getValueFromExcel(), ilDclStandardField\getValueFromExcel(), and ilDclTextRecordFieldModel\getValueFromExcel().

+ Here is the caller graph for this function:

◆ getColumnCoord()

ilExcel::getColumnCoord ( int  $a_col)

Get column "name" from number.

Definition at line 386 of file class.ilExcel.php.

386 : string
387 {
388 $col = $this->columnIndexAdjustment($a_col);
389 return Coordinate::stringFromColumnIndex($col);
390 }
columnIndexAdjustment(int $column)
Adjustment needed because of migration PHPExcel to PhpSpreadsheet.

Referenced by ilSumScoreTableGUI\fillHeaderExcel(), ilTable2GUI\fillHeaderExcel(), ilTrMatrixTableGUI\fillHeaderExcel(), ilTrObjectUsersPropsTableGUI\fillHeaderExcel(), ilTrSummaryTableGUI\fillHeaderExcel(), and ilTrUserObjectsPropsTableGUI\fillHeaderExcel().

+ Here is the caller graph for this function:

◆ getColumnCount()

ilExcel::getColumnCount ( )

Returns the number of columns the sheet contains.

Definition at line 378 of file class.ilExcel.php.

378 : int
379 {
380 return Coordinate::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn());
381 }

◆ getCoordByColumnAndRow()

ilExcel::getCoordByColumnAndRow ( int  $pColumn = 1,
int  $pRow = 1 
)

Get cell coordinate (e.g.

"B2") for column and row number

Definition at line 552 of file class.ilExcel.php.

555 : string {
556 $col = $this->columnIndexAdjustment($pColumn);
557 $columnLetter = Coordinate::stringFromColumnIndex($col);
558
559 return $columnLetter . $pRow;
560 }

◆ getSheetAsArray()

ilExcel::getSheetAsArray ( )

Returns the active sheet as an array.

Definition at line 370 of file class.ilExcel.php.

370 : array
371 {
372 return $this->workbook->getActiveSheet()->toArray();
373 }

◆ getSheetCount()

ilExcel::getSheetCount ( )

Returns number of sheets.

Definition at line 159 of file class.ilExcel.php.

159 : int
160 {
161 return $this->workbook->getSheetCount();
162 }

◆ getSheetTitle()

ilExcel::getSheetTitle ( )

Return the current sheet title.

Definition at line 168 of file class.ilExcel.php.

168 : string
169 {
170 return $this->workbook->getActiveSheet()->getTitle();
171 }

◆ getValidFormats()

ilExcel::getValidFormats ( )
Returns
list<string>

Definition at line 97 of file class.ilExcel.php.

97 : array
98 {
100 }
const FORMAT_BIFF
const FORMAT_XML

References FORMAT_BIFF, and FORMAT_XML.

Referenced by setFormat().

+ Here is the caller graph for this function:

◆ loadFromFile()

ilExcel::loadFromFile ( string  $filename)

Loads a spreadsheet from file.

Definition at line 85 of file class.ilExcel.php.

85 : void
86 {
87 $this->workbook = IOFactory::load($filename);
88 }
$filename
Definition: buildRTE.php:78

References $filename.

◆ mergeCells()

ilExcel::mergeCells ( string  $coordinatesRange)
Parameters
string$coordinatesRangeA coordinates range string like 'A1:B5'
Exceptions

PhpOffice\PhpSpreadsheet\Exception

Definition at line 587 of file class.ilExcel.php.

587 : void
588 {
589 $this->workbook->getActiveSheet()->mergeCells($coordinatesRange);
590 }

◆ prepareBooleanValue()

ilExcel::prepareBooleanValue ( bool  $a_value)
protected

Definition at line 220 of file class.ilExcel.php.

220 : string
221 {
223
224 return $a_value ? $lng->txt('yes') : $lng->txt('no');
225 }
ilLanguage $lng
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...

References $lng.

◆ prepareDateValue()

ilExcel::prepareDateValue ( ilDateTime  $a_value)
protected
Parameters
ilDateTime$a_value
Returns
false|float

Definition at line 205 of file class.ilExcel.php.

206 {
207 switch (true) {
208 case $a_value instanceof ilDate:
209 $a_value = Date::stringToExcel($a_value->get(IL_CAL_DATE));
210 break;
211
212 default:
213 $a_value = Date::stringToExcel($a_value->get(IL_CAL_DATETIME));
214 break;
215 }
216
217 return $a_value;
218 }
const IL_CAL_DATE
const IL_CAL_DATETIME
get(int $a_format, string $a_format_str='', string $a_tz='')
get formatted date
Class for single dates.

References ilDateTime\get(), IL_CAL_DATE, and IL_CAL_DATETIME.

+ Here is the call graph for this function:

◆ prepareStorage()

ilExcel::prepareStorage ( string  $a_file_name)
protected

Prepare workbook for storage/delivery.

Definition at line 416 of file class.ilExcel.php.

416 : string
417 {
418 $this->setGlobalAutoSize();
419 $this->workbook->setActiveSheetIndex(0);
420
421 switch ($this->format) {
423 if (stripos($a_file_name, '.xls') === false) {
424 $a_file_name .= '.xls';
425 }
426 break;
427
428 case self::FORMAT_XML:
429 if (stripos($a_file_name, '.xlsx') === false) {
430 $a_file_name .= '.xlsx';
431 }
432 break;
433 }
434
435 return $a_file_name;
436 }
setGlobalAutoSize()
Set all existing columns on all sheets to autosize.

◆ prepareString()

ilExcel::prepareString ( string  $value)
protected

Definition at line 227 of file class.ilExcel.php.

229 : string {
230 if (!mb_check_encoding($value, 'UTF-8')) {
231 throw new InvalidArgumentException('Invalid UTF-8 passed.');
232 }
233
234 return $this->cleanupNonCharachters(strip_tags($value));
235 }
cleanupNonCharachters(string $string)

◆ prepareValue()

ilExcel::prepareValue (   $value)
protected

Prepare value for cell.

Parameters
mixed$value
Returns
mixed
Exceptions
InvalidArgumentException

Definition at line 184 of file class.ilExcel.php.

185 {
186 if (is_bool($value)) {
187 return $this->prepareBooleanValue($value);
188 }
189
190 if ($value instanceof ilDateTime) {
191 return $this->prepareDateValue($value);
192 }
193
194 if (is_string($value)) {
195 return $this->prepareString($value);
196 }
197
198 return $value;
199 }
@classDescription Date and time handling
prepareString(string $value,)
prepareDateValue(ilDateTime $a_value)
prepareBooleanValue(bool $a_value)

◆ sendToClient()

ilExcel::sendToClient ( string  $a_file_name)

Send workbook to client.

Exceptions

PhpOffice\PhpSpreadsheet\Writer\Exception

Definition at line 442 of file class.ilExcel.php.

442 : void
443 {
444 $a_file_name = $this->prepareStorage($a_file_name);
445 switch ($this->format) {
447 $a_mime_type = MimeType::APPLICATION__VND_MS_EXCEL;
448 break;
449
450 case self::FORMAT_XML:
451 $a_mime_type = MimeType::APPLICATION__VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET;
452 break;
453 default:
454 $a_mime_type = MimeType::APPLICATION__OCTET_STREAM;
455 break;
456 }
457 $tmp_name = ilFileUtils::ilTempnam();
458
459 $writer = IOFactory::createWriter($this->workbook, $this->format);
460 $writer->save($tmp_name);
461
462 ilFileDelivery::deliverFileAttached($tmp_name, $a_file_name, $a_mime_type, true);
463 }
prepareStorage(string $a_file_name)
Prepare workbook for storage/delivery.
static deliverFileAttached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, bool $delete_file=false)
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.

References ilFileDelivery\deliverFileAttached(), and ilFileUtils\ilTempnam().

+ Here is the call graph for this function:

◆ setActiveSheet()

ilExcel::setActiveSheet ( int  $a_index)
Exceptions

PhpOffice\PhpSpreadsheet\Exception

Definition at line 150 of file class.ilExcel.php.

150 : void
151 {
152 $this->workbook->setActiveSheetIndex($a_index);
153 }

◆ setBold()

ilExcel::setBold ( string  $a_coords)

Set cell(s) to bold.

Definition at line 493 of file class.ilExcel.php.

493 : void
494 {
495 $this->workbook->getActiveSheet()->getStyle($a_coords)->getFont()->setBold(true);
496 }

Referenced by ilSumScoreTableGUI\fillHeaderExcel(), ilTable2GUI\fillHeaderExcel(), ilLPProgressTableGUI\fillHeaderExcel(), ilTrMatrixTableGUI\fillHeaderExcel(), ilTrObjectUsersPropsTableGUI\fillHeaderExcel(), ilTrSummaryTableGUI\fillHeaderExcel(), and ilTrUserObjectsPropsTableGUI\fillHeaderExcel().

+ Here is the caller graph for this function:

◆ setBorders()

ilExcel::setBorders ( string  $a_coords,
bool  $a_top,
bool  $a_right = false,
bool  $a_bottom = false,
bool  $a_left = false 
)

Toggle cell(s) borders.

Definition at line 525 of file class.ilExcel.php.

531 : void {
532 $style = $this->workbook->getActiveSheet()->getStyle($a_coords);
533
534 // :TODO: border styles?
535 if ($a_top) {
536 $style->getBorders()->getTop()->setBorderStyle(Border::BORDER_THIN);
537 }
538 if ($a_right) {
539 $style->getBorders()->getRight()->setBorderStyle(Border::BORDER_THIN);
540 }
541 if ($a_bottom) {
542 $style->getBorders()->getBottom()->setBorderStyle(Border::BORDER_THIN);
543 }
544 if ($a_left) {
545 $style->getBorders()->getLeft()->setBorderStyle(Border::BORDER_THIN);
546 }
547 }

◆ setCell()

ilExcel::setCell ( int  $a_row,
int  $col,
  $value,
?string  $datatype = null 
)

Set cell value.

Parameters
int$a_row
int$col
mixed$value
?string$datatype Explicit data type, see DataType::TYPE_*

Definition at line 288 of file class.ilExcel.php.

293 : void {
294 $coordinate = $this->getCoordByColumnAndRow($col, $a_row);
295
296 if ($datatype === DataType::TYPE_STRING) {
297 $this->workbook->getActiveSheet()->setCellValueExplicit(
298 $coordinate,
299 $this->prepareString($value),
300 $datatype
301 );
302 } elseif ($datatype !== null) {
303 $this->workbook->getActiveSheet()->setCellValueExplicit(
304 $coordinate,
305 $this->prepareValue($value),
306 $datatype
307 );
308 } elseif ($value instanceof ilDateTime) {
309 $wb = $this->workbook->getActiveSheet()->setCellValue(
310 $coordinate,
311 $this->prepareValue($value)
312 );
313 $this->setDateFormat($wb->getCell($coordinate), $value);
314 } elseif (is_numeric($value)) {
315 $this->workbook->getActiveSheet()->setCellValueExplicit(
316 $coordinate,
317 $this->prepareValue($value),
318 DataType::TYPE_NUMERIC
319 );
320 } else {
321 $this->workbook->getActiveSheet()->setCellValueExplicit(
322 $coordinate,
323 $this->prepareValue($value),
324 DataType::TYPE_STRING
325 );
326 }
327 }
prepareValue($value)
Prepare value for cell.
setDateFormat(Cell $a_cell, $a_value)
Set date format of cell.

Referenced by ILIAS\Test\Logging\TestLogViewer\addRowsFromLogs(), ilDclBaseRecordFieldModel\fillExcelExport(), ilDclTextRecordFieldModel\fillExcelExport(), ilDclTextSelectionRecordFieldModel\fillExcelExport(), ilBookingReservationsTableGUI\fillHeaderExcel(), ilSCORM2004TrackingItemsTableGUI\fillHeaderExcel(), ilSCORMTrackingItemsTableGUI\fillHeaderExcel(), ilSumScoreTableGUI\fillHeaderExcel(), ilTable2GUI\fillHeaderExcel(), ilLPProgressTableGUI\fillHeaderExcel(), ilTrMatrixTableGUI\fillHeaderExcel(), ilTrObjectUsersPropsTableGUI\fillHeaderExcel(), ilTrSummaryTableGUI\fillHeaderExcel(), ilTrUserObjectsPropsTableGUI\fillHeaderExcel(), ilDclBaseFieldModel\fillHeaderExcel(), ilDclStandardField\fillHeaderExcel(), ilDclTextFieldModel\fillHeaderExcel(), ilLPTableBaseGUI\fillMetaExcel(), ilDclBaseRecordModel\fillRecordFieldExcelExport(), ILIAS\MyStaff\ListCertificates\ilMStListCertificatesTableGUI\fillRowExcel(), ILIAS\MyStaff\ListCompetences\Skills\ilMStListCompetencesSkillsTableGUI\fillRowExcel(), ILIAS\MyStaff\ListUsers\ilMStListUsersTableGUI\fillRowExcel(), ilBookingReservationsTableGUI\fillRowExcel(), ilMStListCoursesTableGUI\fillRowExcel(), ilMStShowUserCoursesTableGUI\fillRowExcel(), ilPollAnswerTableGUI\fillRowExcel(), ilPollUserTableGUI\fillRowExcel(), ilSCORM2004TrackingItemsTableGUI\fillRowExcel(), ilSCORMTrackingItemsTableGUI\fillRowExcel(), ilSumScoreTableGUI\fillRowExcel(), ilTable2GUI\fillRowExcel(), ilLPObjectStatisticsDailyTableGUI\fillRowExcel(), ilLPObjectStatisticsTableGUI\fillRowExcel(), ilLPObjectStatisticsTypesTableGUI\fillRowExcel(), ilLPProgressTableGUI\fillRowExcel(), ilTrMatrixTableGUI\fillRowExcel(), ilTrObjectUsersPropsTableGUI\fillRowExcel(), ilTrSummaryTableGUI\fillRowExcel(), ilTrUserObjectsPropsTableGUI\fillRowExcel(), and ilUserLPTableGUI\fillRowExcel().

+ Here is the caller graph for this function:

◆ setCellArray()

ilExcel::setCellArray ( array  $a_values,
string  $a_top_left = 'A1',
  $a_null_value = null 
)

Set cell values from array.

Parameters
array<int,mixed|array<int,mixed>>$a_values
string$a_top_left
mixed$a_null_valueValue in source array that stands for blank cell

Definition at line 336 of file class.ilExcel.php.

340 : void {
341 foreach ($a_values as $row_idx => $cols) {
342 if (is_array($cols)) {
343 foreach ($cols as $col_idx => $col_value) {
344 $a_values[$row_idx][$col_idx] = $this->prepareValue($col_value);
345 }
346 } else {
347 $a_values[$row_idx] = $this->prepareValue($cols);
348 }
349 }
350
351 $this->workbook->getActiveSheet()->fromArray($a_values, $a_null_value, $a_top_left);
352 }

◆ setCellByCoordinates()

ilExcel::setCellByCoordinates (   $a_coords,
  $a_value 
)

Set cell value by coordinates.

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

Definition at line 257 of file class.ilExcel.php.

257 : void
258 {
259 if ($a_value instanceof ilDateTime) {
260 $wb = $this->workbook->getActiveSheet()->setCellValue(
261 $a_coords,
262 $this->prepareValue($a_value)
263 );
264 $cell = $wb->getCell($a_coords);
265 $this->setDateFormat($cell, $a_value);
266 } elseif (is_numeric($a_value)) {
267 $this->workbook->getActiveSheet()->setCellValueExplicit(
268 $a_coords,
269 $this->prepareValue($a_value),
270 DataType::TYPE_NUMERIC
271 );
272 } else {
273 $this->workbook->getActiveSheet()->setCellValueExplicit(
274 $a_coords,
275 $this->prepareValue($a_value),
276 DataType::TYPE_STRING
277 );
278 }
279 }

◆ setColors()

ilExcel::setColors ( string  $a_coords,
string  $a_background,
?string  $a_font = null 
)

Set cell(s) colors.

Definition at line 501 of file class.ilExcel.php.

505 : void {
506 $opts = [
507 'fill' => [
508 'fillType' => Fill::FILL_SOLID,
509 'color' => ['rgb' => $a_background]
510 ]
511 ];
512
513 if ($a_font) {
514 $opts['font'] = [
515 'color' => ['rgb' => $a_font]
516 ];
517 }
518
519 $this->workbook->getActiveSheet()->getStyle($a_coords)->applyFromArray($opts);
520 }

◆ setDateFormat()

ilExcel::setDateFormat ( Cell  $a_cell,
  $a_value 
)
protected

Set date format of cell.

Parameters
Cell$a_cell
mixed$a_value

Definition at line 243 of file class.ilExcel.php.

243 : void
244 {
245 if ($a_value instanceof ilDate) {
246 $a_cell->getStyle()->getNumberFormat()->setFormatCode('dd.mm.yyyy');
247 } elseif ($a_value instanceof ilDateTime) {
248 $a_cell->getStyle()->getNumberFormat()->setFormatCode('dd.mm.yyyy hh:mm:ss');
249 }
250 }

◆ setFormat()

ilExcel::setFormat ( string  $a_format)

Set file format.

Definition at line 105 of file class.ilExcel.php.

105 : void
106 {
107 if (in_array($a_format, $this->getValidFormats())) {
108 $this->format = $a_format;
109 }
110 }
getValidFormats()

References getValidFormats().

Referenced by __construct().

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

◆ setGlobalAutoSize()

ilExcel::setGlobalAutoSize ( )
protected

Set all existing columns on all sheets to autosize.

Definition at line 395 of file class.ilExcel.php.

395 : void
396 {
397 // this may change the active sheet
398 foreach ($this->workbook->getWorksheetIterator() as $worksheet) {
399 $this->workbook->setActiveSheetIndex($this->workbook->getIndex($worksheet));
400 $sheet = $this->workbook->getActiveSheet();
401 $cellIterator = $sheet->getRowIterator()->current()->getCellIterator();
402 $cellIterator->setIterateOnlyExistingCells(true);
403 foreach ($cellIterator as $cell) {
404 $sheet->getColumnDimension($cell->getColumn())->setAutoSize(true);
405 }
406 }
407 }

◆ writeToFile()

ilExcel::writeToFile ( string  $a_file)

Save workbook to file.

Exceptions

PhpOffice\PhpSpreadsheet\Writer\Exception

Definition at line 470 of file class.ilExcel.php.

470 : void
471 {
472 $a_file = $this->prepareStorage($a_file);
473
474 $writer = IOFactory::createWriter($this->workbook, $this->format);
475 $writer->save($a_file);
476 }

◆ writeToTmpFile()

ilExcel::writeToTmpFile ( )
Exceptions

PhpOffice\PhpSpreadsheet\Writer\Exception

Definition at line 481 of file class.ilExcel.php.

481 : string
482 {
483 $writer = IOFactory::createWriter($this->workbook, $this->format);
485 $writer->save($filename);
486
487 return $filename;
488 }

References $filename, and ilFileUtils\ilTempnam().

+ Here is the call graph for this function:

Field Documentation

◆ $format

string ilExcel::$format
protected

Definition at line 38 of file class.ilExcel.php.

◆ $lng

ilLanguage ilExcel::$lng
protected

Definition at line 61 of file class.ilExcel.php.

◆ $noncharacters

array ilExcel::$noncharacters
private
Initial value:
= [
'\x{FFFE}-\x{FFFF}',
'\x{1FFFE}-\x{1FFFF}',
'\x{2FFFE}-\x{2FFFF}',
'\x{3FFFE}-\x{3FFFF}',
'\x{4FFFE}-\x{4FFFF}',
'\x{5FFFE}-\x{5FFFF}',
'\x{6FFFE}-\x{6FFFF}',
'\x{7FFFE}-\x{7FFFF}',
'\x{8FFFE}-\x{8FFFF}',
'\x{9FFFE}-\x{9FFFF}',
'\x{AFFFE}-\x{AFFFF}',
'\x{BFFFE}-\x{BFFFF}',
'\x{CFFFE}-\x{CFFFF}',
'\x{DFFFE}-\x{DFFFF}',
'\x{EFFFE}-\x{EFFFF}',
'\x{FFFFE}-\x{FFFFF}',
'\x{10FFFE}-\x{10FFFF}',
'\x{FDD0}-\x{FDEF}'
]

Definition at line 40 of file class.ilExcel.php.

◆ $type

string ilExcel::$type
protected

Definition at line 63 of file class.ilExcel.php.

◆ $workbook

Spreadsheet ilExcel::$workbook
protected

Definition at line 62 of file class.ilExcel.php.

◆ FORMAT_BIFF

const ilExcel::FORMAT_BIFF = 'Xls'

Definition at line 37 of file class.ilExcel.php.

Referenced by getValidFormats().

◆ FORMAT_XML

const ilExcel::FORMAT_XML = 'Xlsx'

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