ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilExcel Class Reference
+ Inheritance diagram for ilExcel:
+ Collaboration diagram for ilExcel:

Public Member Functions

 __construct ()
 Constructor. More...
 
 loadFromFile ($filename)
 Loads a spreadsheet from file. More...
 
 getValidFormats ()
 Get valid file formats. More...
 
 setFormat ($a_format)
 Set file format. More...
 
 addSheet ($a_name, $a_activate=true)
 Add sheet. More...
 
 setActiveSheet ($a_index)
 Set active sheet. More...
 
 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 ($a_row, $a_col, $a_value, $a_datatype=null)
 Set cell value. More...
 
 setCellArray (array $a_values, $a_top_left="A1", $a_null_value=null)
 Set cell values from array. More...
 
 getCell ($a_row, $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 ($a_col)
 Get column "name" from number. More...
 
 sendToClient ($a_file_name)
 Send workbook to client. More...
 
 writeToFile ($a_file)
 Save workbook to file. More...
 
 writeToTmpFile ()
 
 setBold ($a_coords)
 Set cell(s) to bold. More...
 
 setColors ($a_coords, $a_background, $a_font=null)
 Set cell(s) colors. More...
 
 setBorders ($a_coords, $a_top, $a_right=false, $a_bottom=false, $a_left=false)
 Toggle cell(s) borders. More...
 
 getCoordByColumnAndRow ($pColumn=1, $pRow=1)
 Get cell coordinate (e.g. More...
 
 addLink ($a_row, $a_column, $a_path)
 
 columnIndexAdjustment (int $column)
 Adjustment needed because of migration PHPExcel to PhpSpreadsheet. More...
 

Data Fields

const FORMAT_XML = "Xlsx"
 
const FORMAT_BIFF = "Xls"
 

Protected Member Functions

 prepareValue ($a_value)
 Prepare value for cell. More...
 
 prepareDateValue (ilDateTime $a_value)
 
 prepareBooleanValue ($a_value)
 
 prepareString ($a_value)
 
 setDateFormat (Cell $a_cell, $a_value)
 Set date format. More...
 
 setGlobalAutoSize ()
 Set all existing columns on all sheets to autosize. More...
 
 prepareStorage ($a_file_name)
 Prepare workbook for storage/delivery. More...
 

Protected Attributes

 $lng
 
 $workbook
 
 $type
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilExcel::__construct ( )

Constructor.

Returns
self

Reimplemented in ilAssExcelFormatHelper.

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

48 {
49 global $DIC;
50
51 $this->lng = $DIC->language();
52 $this->setFormat(self::FORMAT_XML);
53 $this->workbook = new Spreadsheet();
54 $this->workbook->removeSheetByIndex(0);
55 }
setFormat($a_format)
Set file format.
global $DIC
Definition: saml.php:7

References $DIC, and setFormat().

+ Here is the call graph for this function:

Member Function Documentation

◆ addLink()

ilExcel::addLink (   $a_row,
  $a_column,
  $a_path 
)
Parameters
$a_rowint
$a_columnint
$a_path

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

583 {
584 $column = $this->columnIndexAdjustment($a_column);
585
586 $this->workbook->getActiveSheet()->getCellByColumnAndRow($column, $a_row)->getHyperlink()->setUrl($a_path);
587 }
columnIndexAdjustment(int $column)
Adjustment needed because of migration PHPExcel to PhpSpreadsheet.

References columnIndexAdjustment().

+ Here is the call graph for this function:

◆ addSheet()

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

Add sheet.

Parameters
string$a_name
bool$a_activate
Returns
int index

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

109 {
110 #20749
111 // see Worksheet::$_invalidCharacters;
112 $invalid = array('*', ':', '/', '\\', '?', '[', ']', '\'-','\'');
113
114 $a_name = str_replace($invalid, "", $a_name);
115
116 // #19056 - phpExcel only allows 31 chars
117 // see https://github.com/PHPOffice/PHPExcel/issues/79
118 $a_name = ilUtil::shortenText($a_name, 31);
119
120 $sheet = new Worksheet($this->workbook, $a_name);
121 $this->workbook->addSheet($sheet);
122 $new_index = $this->workbook->getSheetCount() - 1;
123
124 if ((bool) $a_activate) {
125 $this->setActiveSheet($new_index);
126 }
127
128 return $new_index;
129 }
setActiveSheet($a_index)
Set active sheet.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.

References setActiveSheet(), and ilUtil\shortenText().

Referenced by ilSurveyEvaluationGUI\exportResultsDetailsExcel().

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

◆ 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

Parameters
$column
Returns
int

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

595 : int
596 {
597 return ++$column;
598 }

Referenced by addLink(), getCell(), getColumnCoord(), getCoordByColumnAndRow(), and setCell().

+ Here is the caller graph for this function:

◆ getCell()

ilExcel::getCell (   $a_row,
  $a_col 
)

Returns the value of a cell.

Parameters
int$a_row
int$a_col
Returns
mixed

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

351 {
352 $col = $this->columnIndexAdjustment($a_col);
353
354 return $this->workbook->getActiveSheet()->getCellByColumnAndRow($col, $a_row)->getValue();
355 }

References columnIndexAdjustment().

+ Here is the call graph for this function:

◆ getColumnCoord()

ilExcel::getColumnCoord (   $a_col)

Get column "name" from number.

Parameters
int$a_col
Returns
string

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

386 {
387 $col = $this->columnIndexAdjustment($a_col);
388
389 return Coordinate::stringFromColumnIndex($col);
390 }

References columnIndexAdjustment().

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

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

◆ getColumnCount()

ilExcel::getColumnCount ( )

Returns the number of columns the sheet contains.

Returns
int

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

375 {
376 return Coordinate::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn());
377 }

◆ getCoordByColumnAndRow()

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

Get cell coordinate (e.g.

"B2") for column and row number

Parameters
int$pColumn
int$pRow
Returns
string

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

570 {
571 $col = $this->columnIndexAdjustment($pColumn);
572 $columnLetter = Coordinate::stringFromColumnIndex($col);
573
574 return $columnLetter . $pRow;
575 }

References columnIndexAdjustment().

Referenced by ilSurveyEvaluationGUI\exportResultsDetailsExcel().

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

◆ getSheetAsArray()

ilExcel::getSheetAsArray ( )

Returns the active sheet as an array.

Returns
array

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

364 {
365 return $this->workbook->getActiveSheet()->toArray();
366 }

◆ getSheetCount()

ilExcel::getSheetCount ( )

Returns number of sheets.

Returns
int

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

148 {
149 return $this->workbook->getSheetCount();
150 }

◆ getSheetTitle()

ilExcel::getSheetTitle ( )

Return the current sheet title.

Returns
string

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

159 {
160 return $this->workbook->getActiveSheet()->getTitle();
161 }

◆ getValidFormats()

ilExcel::getValidFormats ( )

Get valid file formats.

Returns
array

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

80 {
81 return array(self::FORMAT_XML, self::FORMAT_BIFF);
82 }

Referenced by setFormat().

+ Here is the caller graph for this function:

◆ loadFromFile()

ilExcel::loadFromFile (   $filename)

Loads a spreadsheet from file.

Parameters
$filename

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

66 {
67 $this->workbook = IOFactory::load($filename);
68 }
$filename
Definition: buildRTE.php:89

References $filename.

◆ prepareBooleanValue()

ilExcel::prepareBooleanValue (   $a_value)
protected
Parameters
bool$a_value
Returns
string

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

214 {
216
217 return $a_value ? $lng->txt('yes') : $lng->txt('no');
218 }

References $lng.

Referenced by prepareValue().

+ Here is the caller graph for this function:

◆ prepareDateValue()

ilExcel::prepareDateValue ( ilDateTime  $a_value)
protected
Parameters
ilDateTime$a_value
Returns
string

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

195 {
196 switch (true) {
197 case $a_value instanceof ilDate:
198 $a_value = Date::stringToExcel($a_value->get(IL_CAL_DATE));
199 break;
200
201 default:
202 $a_value = Date::stringToExcel($a_value->get(IL_CAL_DATETIME));
203 break;
204 }
205
206 return $a_value;
207 }
const IL_CAL_DATE
const IL_CAL_DATETIME
get($a_format, $a_format_str='', $a_tz='')
get formatted date
Class for single dates.

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

Referenced by prepareValue().

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

◆ prepareStorage()

ilExcel::prepareStorage (   $a_file_name)
protected

Prepare workbook for storage/delivery.

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

417 {
418 $this->setGlobalAutoSize();
419 $this->workbook->setActiveSheetIndex(0);
420
421 switch ($this->format) {
423 if (!stristr($a_file_name, ".xls")) {
424 $a_file_name .= ".xls";
425 }
426 break;
427
428 case self::FORMAT_XML:
429 if (!stristr($a_file_name, ".xlsx")) {
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.
const FORMAT_BIFF
const FORMAT_XML

References FORMAT_BIFF, FORMAT_XML, and setGlobalAutoSize().

Referenced by sendToClient(), and writeToFile().

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

◆ prepareString()

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

Reimplemented in ilAssExcelFormatHelper.

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

225 {
226 return strip_tags($a_value); // #14542
227 }

Referenced by prepareValue().

+ Here is the caller graph for this function:

◆ prepareValue()

ilExcel::prepareValue (   $a_value)
protected

Prepare value for cell.

Parameters
mixed$a_value
Returns
mixed

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

175 {
177
178 // :TODO: does this make sense?
179 if (is_bool($a_value)) {
180 $a_value = $this->prepareBooleanValue($a_value);
181 } elseif ($a_value instanceof ilDateTime) {
182 $a_value = $this->prepareDateValue($a_value);
183 } elseif (is_string($a_value)) {
184 $a_value = $this->prepareString($a_value);
185 }
186
187 return $a_value;
188 }
@classDescription Date and time handling
prepareString($a_value)
prepareDateValue(ilDateTime $a_value)
prepareBooleanValue($a_value)

References $lng, prepareBooleanValue(), prepareDateValue(), and prepareString().

Referenced by setCell(), ilAssExcelFormatHelper\setCell(), setCellArray(), ilAssExcelFormatHelper\setCellByCoordinates(), and setCellByCoordinates().

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

◆ sendToClient()

ilExcel::sendToClient (   $a_file_name)

Send workbook to client.

Parameters
string$a_file_name

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

444 {
445 require_once('./Services/FileDelivery/classes/class.ilPHPOutputDelivery.php');
446
447 $a_file_name = $this->prepareStorage($a_file_name);
448 switch ($this->format) {
451 break;
452
453 case self::FORMAT_XML:
455 break;
456 default:
458 break;
459 }
460 $tmp_name = ilUtil::ilTempnam();
461
462 $writer = IOFactory::createWriter($this->workbook, $this->format);
463 $writer->save($tmp_name);
464
465 ilFileDelivery::deliverFileAttached($tmp_name, $a_file_name, $a_mime_type, true);
466 }
prepareStorage($a_file_name)
Prepare workbook for storage/delivery.
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
const APPLICATION__VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.

References ilMimeTypeUtil\APPLICATION__OCTET_STREAM, ilMimeTypeUtil\APPLICATION__VND_MS_EXCEL, ilMimeTypeUtil\APPLICATION__VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET, ilFileDelivery\deliverFileAttached(), FORMAT_BIFF, FORMAT_XML, ilUtil\ilTempnam(), and prepareStorage().

+ Here is the call graph for this function:

◆ setActiveSheet()

ilExcel::setActiveSheet (   $a_index)

Set active sheet.

Parameters
int$a_index

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

137 {
138 $this->workbook->setActiveSheetIndex($a_index);
139 }

Referenced by addSheet().

+ Here is the caller graph for this function:

◆ setBold()

ilExcel::setBold (   $a_coords)

◆ setBorders()

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

Toggle cell(s) borders.

Parameters
string$a_coords
bool$a_top
bool$a_right
bool$a_bottom
bool$a_left

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

544 {
545 $style = $this->workbook->getActiveSheet()->getStyle($a_coords);
546
547 // :TODO: border styles?
548 if ($a_top) {
549 $style->getBorders()->getTop()->setBorderStyle(Border::BORDER_THIN);
550 }
551 if ($a_right) {
552 $style->getBorders()->getRight()->setBorderStyle(Border::BORDER_THIN);
553 }
554 if ($a_bottom) {
555 $style->getBorders()->getBottom()->setBorderStyle(Border::BORDER_THIN);
556 }
557 if ($a_left) {
558 $style->getBorders()->getLeft()->setBorderStyle(Border::BORDER_THIN);
559 }
560 }
$style
Definition: example_012.php:70

References $style.

◆ setCell()

ilExcel::setCell (   $a_row,
  $a_col,
  $a_value,
  $a_datatype = null 
)

Set cell value.

Parameters
int$a_row
int$a_col
mixed$a_value
null$a_datatype
Exceptions

PhpOffice\PhpSpreadsheet\Exception

Reimplemented in ilAssExcelFormatHelper.

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

285 {
286 $col = $this->columnIndexAdjustment($a_col);
287
288 if (!is_null($a_datatype)) {
289 $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
290 $col,
291 $a_row,
292 $this->prepareValue($a_value),
293 $a_datatype
294 );
295 } elseif ($a_value instanceof ilDateTime) {
296 $wb = $this->workbook->getActiveSheet()->setCellValueByColumnAndRow(
297 $col,
298 $a_row,
299 $this->prepareValue($a_value)
300 );
301 $this->setDateFormat($wb->getCellByColumnAndRow($col, $a_row), $a_value);
302 } elseif (is_numeric($a_value)) {
303 $wb = $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
304 $col,
305 $a_row,
306 $this->prepareValue($a_value),
307 DataType::TYPE_NUMERIC
308 );
309 } else {
310 $wb = $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
311 $col,
312 $a_row,
313 $this->prepareValue($a_value),
314 DataType::TYPE_STRING
315 );
316 }
317 }
prepareValue($a_value)
Prepare value for cell.
setDateFormat(Cell $a_cell, $a_value)
Set date format.

References columnIndexAdjustment(), prepareValue(), and setDateFormat().

Referenced by ilSurveyEvaluationGUI\exportResultsDetailsExcel(), ilDclBaseRecordFieldModel\fillExcelExport(), ilDclTextRecordFieldModel\fillExcelExport(), ilDclTextSelectionRecordFieldModel\fillExcelExport(), ilBookingReservationsTableGUI\fillHeaderExcel(), ilTable2GUI\fillHeaderExcel(), ilLPProgressTableGUI\fillHeaderExcel(), ilTrMatrixTableGUI\fillHeaderExcel(), ilTrObjectUsersPropsTableGUI\fillHeaderExcel(), ilTrSummaryTableGUI\fillHeaderExcel(), ilTrUserObjectsPropsTableGUI\fillHeaderExcel(), ilSCORM2004TrackingItemsTableGUI\fillHeaderExcel(), ilSCORMTrackingItemsTableGUI\fillHeaderExcel(), ilDclBaseFieldModel\fillHeaderExcel(), ilDclStandardField\fillHeaderExcel(), ilDclTextFieldModel\fillHeaderExcel(), ilLPTableBaseGUI\fillMetaExcel(), ilDclBaseRecordModel\fillRecordFieldExcelExport(), ilBookingReservationsTableGUI\fillRowExcel(), ilPollAnswerTableGUI\fillRowExcel(), ilPollUserTableGUI\fillRowExcel(), ilTable2GUI\fillRowExcel(), ilLPObjectStatisticsDailyTableGUI\fillRowExcel(), ilLPObjectStatisticsTableGUI\fillRowExcel(), ilLPObjectStatisticsTypesTableGUI\fillRowExcel(), ilLPProgressTableGUI\fillRowExcel(), ilTrMatrixTableGUI\fillRowExcel(), ilTrObjectUsersPropsTableGUI\fillRowExcel(), ilTrSummaryTableGUI\fillRowExcel(), ilTrUserObjectsPropsTableGUI\fillRowExcel(), ilUserLPTableGUI\fillRowExcel(), ilMStListCoursesTableGUI\fillRowExcel(), ilMStShowUserCoursesTableGUI\fillRowExcel(), ilMStListUsersTableGUI\fillRowExcel(), ilSCORM2004TrackingItemsTableGUI\fillRowExcel(), ilSCORMTrackingItemsTableGUI\fillRowExcel(), and ilSurveyEvaluationGUI\parseResultsToExcel().

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

◆ setCellArray()

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

Set cell values from array.

Parameters
array$a_values
string$a_top_left
mixed$a_null_value

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

327 {
328 foreach ($a_values as $row_idx => $cols) {
329 if (is_array($cols)) {
330 foreach ($cols as $col_idx => $col_value) {
331 $a_values[$row_idx][$col_idx] = $this->prepareValue($col_value);
332 }
333 } else {
334 $a_values[$row_idx] = $this->prepareValue($cols);
335 }
336 }
337
338 $this->workbook->getActiveSheet()->fromArray($a_values, $a_null_value, $a_top_left);
339 }
$cols
Definition: xhr_table.php:11

References $cols, and prepareValue().

+ Here is the call graph for this function:

◆ setCellByCoordinates()

ilExcel::setCellByCoordinates (   $a_coords,
  $a_value 
)

Set cell value by coordinates.

Parameters
string$a_coords
mixed$a_value

Reimplemented in ilAssExcelFormatHelper.

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

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

References prepareValue(), and setDateFormat().

+ Here is the call graph for this function:

◆ setColors()

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

Set cell(s) colors.

Parameters
string$a_coords
string$a_background
string$a_font

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

517 {
518 $opts = array(
519 'fill' => array(
520 'fillType' => Fill::FILL_SOLID,
521 'color' => array('rgb' => $a_background)
522 )
523 );
524
525 if ($a_font) {
526 $opts['font'] = array(
527 'color' => array('rgb' => $a_font)
528 );
529 }
530
531 $this->workbook->getActiveSheet()->getStyle($a_coords)->applyFromArray($opts);
532 }

Referenced by ilSurveyEvaluationGUI\exportResultsDetailsExcel(), ilSurveyEvaluationGUI\parseResultsToExcel(), and ilAssExcelFormatHelper\setFormattedExcelTitle().

+ Here is the caller graph for this function:

◆ setDateFormat()

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

Set date format.

Parameters
Cell$a_cell
mixed$a_value

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

236 {
237 if ($a_value instanceof ilDate) {
238 // :TODO: i18n?
239 $a_cell->getStyle()->getNumberFormat()->setFormatCode("dd.mm.yyyy");
240 } elseif ($a_value instanceof ilDateTime) {
241 // :TODO: i18n?
242 $a_cell->getStyle()->getNumberFormat()->setFormatCode("dd.mm.yyyy hh:mm:ss");
243 }
244 }
getStyle()
Get cell style.
Definition: Cell.php:533

References PhpOffice\PhpSpreadsheet\Cell\Cell\getStyle().

Referenced by setCell(), and setCellByCoordinates().

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

◆ setFormat()

ilExcel::setFormat (   $a_format)

Set file format.

Parameters
string$a_format

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

90 {
91 if (in_array($a_format, $this->getValidFormats())) {
92 $this->format = $a_format;
93 }
94 }
getValidFormats()
Get valid file formats.

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.

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 }

Referenced by prepareStorage().

+ Here is the caller graph for this function:

◆ writeToFile()

ilExcel::writeToFile (   $a_file)

Save workbook to file.

Parameters
string$a_filefull path

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

474 {
475 $a_file = $this->prepareStorage($a_file);
476
477 $writer = IOFactory::createWriter($this->workbook, $this->format);
478 $writer->save($a_file);
479 }

References prepareStorage().

+ Here is the call graph for this function:

◆ writeToTmpFile()

ilExcel::writeToTmpFile ( )
Returns
string
Exceptions

PHPExcel_Reader_Exception

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

487 {
488 $writer = IOFactory::createWriter($this->workbook, $this->format);
490 $writer->save($filename);
491
492 return $filename;
493 }

References $filename, and ilUtil\ilTempnam().

+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilExcel::$lng
protected

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

Referenced by prepareBooleanValue(), and prepareValue().

◆ $type

ilExcel::$type
protected

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

◆ $workbook

ilExcel::$workbook
protected

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

◆ FORMAT_BIFF

const ilExcel::FORMAT_BIFF = "Xls"

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

Referenced by prepareStorage(), and sendToClient().

◆ FORMAT_XML

const ilExcel::FORMAT_XML = "Xlsx"

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

Referenced by prepareStorage(), and sendToClient().


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