ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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=0, $pRow=1)
 Get cell coordinate (e.g. More...
 

Data Fields

const FORMAT_XML = "Excel2007"
 
const FORMAT_BIFF = "Excel5"
 

Protected Member Functions

 prepareValue ($a_value)
 Prepare value for cell. More...
 
 prepareDateValue (ilDateTime $a_value)
 
 prepareBooleanValue ($a_value)
 
 prepareString ($a_value)
 
 setDateFormat (PHPExcel_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 12 of file class.ilExcel.php.

Constructor & Destructor Documentation

◆ __construct()

ilExcel::__construct ( )

Constructor.

Returns
self

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

References $DIC, setFormat(), and workbook.

38  {
39  global $DIC;
40 
41  $this->lng = $DIC->language();
42  $this->setFormat(self::FORMAT_XML);
43  $this->workbook = new PHPExcel();
44  $this->workbook->removeSheetByIndex(0);
45  }
global $DIC
Definition: saml.php:7
Add a hyperlink to another cell on a different worksheet within the workbook
setFormat($a_format)
Set file format.
+ Here is the call graph for this function:

Member Function Documentation

◆ addSheet()

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

Add sheet.

Parameters
string$a_name
bool$a_activate
Returns
int index

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

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

Referenced by ilSurveyEvaluationGUI\exportResultsDetailsExcel().

99  {
100  // see PHPExcel_Worksheet::$_invalidCharacters;
101  #20749
102  $invalid = array('*', ':', '/', '\\', '?', '[', ']', '\'-','\'');
103 
104  $a_name = str_replace($invalid, "", $a_name);
105 
106  // #19056 - phpExcel only allows 31 chars
107  // see https://github.com/PHPOffice/PHPExcel/issues/79
108  $a_name = ilUtil::shortenText($a_name, 31);
109 
110  $sheet = new PHPExcel_Worksheet($this->workbook, $a_name);
111  $this->workbook->addSheet($sheet);
112  $new_index = $this->workbook->getSheetCount()-1;
113 
114  if ((bool) $a_activate) {
115  $this->setActiveSheet($new_index);
116  }
117 
118  return $new_index;
119  }
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
setActiveSheet($a_index)
Set active sheet.
Add a hyperlink to another cell on a different worksheet within the workbook
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ 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 343 of file class.ilExcel.php.

References workbook.

344  {
345  return $this->workbook->getActiveSheet()->getCellByColumnAndRow($a_col, $a_row)->getValue();
346  }
Add a hyperlink to another cell on a different worksheet within the workbook

◆ getColumnCoord()

ilExcel::getColumnCoord (   $a_col)

Get column "name" from number.

Parameters
int$a_col
Returns
string

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

References PHPExcel_Cell\stringFromColumnIndex().

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

377  {
379  }
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
Definition: Cell.php:825
+ 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 365 of file class.ilExcel.php.

References PHPExcel_Cell\columnIndexFromString(), and workbook.

366  {
367  return PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn());
368  }
Add a hyperlink to another cell on a different worksheet within the workbook
static columnIndexFromString($pString='A')
Column index from string.
Definition: Cell.php:782
+ Here is the call graph for this function:

◆ getCoordByColumnAndRow()

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

Get cell coordinate (e.g.

"B2") for column and row number

Parameters
int$pColumn
int$pRow
Returns
string

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

References PHPExcel_Cell\stringFromColumnIndex().

Referenced by ilSurveyEvaluationGUI\exportResultsDetailsExcel().

559  {
560  $columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
561  return $columnLetter . $pRow;
562  }
static stringFromColumnIndex($pColumnIndex=0)
String from columnindex.
Definition: Cell.php:825
+ 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 354 of file class.ilExcel.php.

References workbook.

355  {
356  return $this->workbook->getActiveSheet()->toArray();
357  }
Add a hyperlink to another cell on a different worksheet within the workbook

◆ getSheetCount()

ilExcel::getSheetCount ( )

Returns number of sheets.

Returns
int

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

References workbook.

138  {
139  return $this->workbook->getSheetCount();
140  }
Add a hyperlink to another cell on a different worksheet within the workbook

◆ getSheetTitle()

ilExcel::getSheetTitle ( )

Return the current sheet title.

Returns
string

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

References workbook.

149  {
150  return $this->workbook->getActiveSheet()->getTitle();
151  }
Add a hyperlink to another cell on a different worksheet within the workbook

◆ getValidFormats()

ilExcel::getValidFormats ( )

Get valid file formats.

Returns
array

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

References array.

Referenced by setFormat().

70  {
71  return array(self::FORMAT_XML, self::FORMAT_BIFF);
72  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ loadFromFile()

ilExcel::loadFromFile (   $filename)

Loads a spreadsheet from file.

Parameters
$filename

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

References $filename, PHPExcel_IOFactory\load(), and workbook.

56  {
58  }
Add a hyperlink to another cell on a different worksheet within the workbook
static load($pFilename)
Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution.
Definition: IOFactory.php:190
+ Here is the call graph for this function:

◆ prepareBooleanValue()

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

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

References $lng.

Referenced by prepareValue().

204  {
205  $lng = $this->lng;
206 
207  return $a_value ? $lng->txt('yes') : $lng->txt('no');
208  }
+ Here is the caller graph for this function:

◆ prepareDateValue()

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

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

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

Referenced by prepareValue().

185  {
186  switch (true) {
187  case $a_value instanceof ilDate:
188  $a_value = PHPExcel_Shared_Date::stringToExcel($a_value->get(IL_CAL_DATE));
189  break;
190 
191  default:
193  break;
194  }
195 
196  return $a_value;
197  }
const IL_CAL_DATETIME
Class for single dates.
static stringToExcel($dateValue='')
Convert a date/time string to Excel time.
Definition: Date.php:350
get($a_format, $a_format_str='', $a_tz='')
get formatted date
const IL_CAL_DATE
+ 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 405 of file class.ilExcel.php.

References format, setGlobalAutoSize(), and workbook.

Referenced by sendToClient(), and writeToFile().

406  {
407  $this->setGlobalAutoSize();
408  $this->workbook->setActiveSheetIndex(0);
409 
410  switch ($this->format) {
411  case self::FORMAT_BIFF:
412  if (!stristr($a_file_name, ".xls")) {
413  $a_file_name .= ".xls";
414  }
415  break;
416 
417  case self::FORMAT_XML:
418  if (!stristr($a_file_name, ".xlsx")) {
419  $a_file_name .= ".xlsx";
420  }
421  break;
422  }
423 
424  return $a_file_name;
425  }
Add a hyperlink to another cell on a different worksheet within the workbook
setGlobalAutoSize()
Set all existing columns on all sheets to autosize.
Write to Excel2007 format
+ 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

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

Referenced by prepareValue().

215  {
216  return strip_tags($a_value); // #14542
217  }
+ 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 164 of file class.ilExcel.php.

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

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

165  {
166  $lng = $this->lng;
167 
168  // :TODO: does this make sense?
169  if (is_bool($a_value)) {
170  $a_value = $this->prepareBooleanValue($a_value);
171  } elseif ($a_value instanceof ilDateTime) {
172  $a_value = $this->prepareDateValue($a_value);
173  } elseif (is_string($a_value)) {
174  $a_value = $this->prepareString($a_value);
175  }
176 
177  return $a_value;
178  }
prepareString($a_value)
prepareBooleanValue($a_value)
Date and time handling
prepareDateValue(ilDateTime $a_value)
+ 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 432 of file class.ilExcel.php.

References ilMimeTypeUtil\APPLICATION__OCTET_STREAM, ilMimeTypeUtil\APPLICATION__VND_MS_EXCEL, ilMimeTypeUtil\APPLICATION__VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET, PHPExcel_IOFactory\createWriter(), ilFileDelivery\deliverFileAttached(), format, ilUtil\ilTempnam(), prepareStorage(), and workbook.

433  {
434  require_once('./Services/FileDelivery/classes/class.ilPHPOutputDelivery.php');
435 
436  $a_file_name = $this->prepareStorage($a_file_name);
437  switch ($this->format) {
438  case self::FORMAT_BIFF:
440  break;
441 
442  case self::FORMAT_XML:
444  break;
445  default:
447  break;
448  }
449  $tmp_name = ilUtil::ilTempnam();
450 
451  $writer = PHPExcel_IOFactory::createWriter($this->workbook, $this->format);
452  $writer->save($tmp_name);
453 
454  ilFileDelivery::deliverFileAttached($tmp_name, $a_file_name, $a_mime_type, true);
455  }
Add a hyperlink to another cell on a different worksheet within the workbook
prepareStorage($a_file_name)
Prepare workbook for storage/delivery.
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
Write to Excel2007 format
const APPLICATION__VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET
+ Here is the call graph for this function:

◆ setActiveSheet()

ilExcel::setActiveSheet (   $a_index)

Set active sheet.

Parameters
int$a_index

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

References workbook.

Referenced by addSheet().

127  {
128  $this->workbook->setActiveSheetIndex($a_index);
129  }
Add a hyperlink to another cell on a different worksheet within the workbook
+ Here is the caller graph for this function:

◆ setBold()

ilExcel::setBold (   $a_coords)

Set cell(s) to bold.

Parameters
string$a_coords

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

References workbook.

Referenced by ilSurveyEvaluationGUI\exportResultsDetailsExcel(), ilLPProgressTableGUI\fillHeaderExcel(), ilTrObjectUsersPropsTableGUI\fillHeaderExcel(), ilTrUserObjectsPropsTableGUI\fillHeaderExcel(), ilTrMatrixTableGUI\fillHeaderExcel(), ilBookingReservationsTableGUI\fillHeaderExcel(), ilTrSummaryTableGUI\fillHeaderExcel(), ilTable2GUI\fillHeaderExcel(), and ilAssExcelFormatHelper\setFormattedExcelTitle().

494  {
495  $this->workbook->getActiveSheet()->getStyle($a_coords)->getFont()->setBold(true);
496  }
Add a hyperlink to another cell on a different worksheet within the workbook
+ Here is the caller graph for this function:

◆ 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 532 of file class.ilExcel.php.

References $style, PHPExcel_Style_Border\BORDER_THIN, and workbook.

533  {
534  $style = $this->workbook->getActiveSheet()->getStyle($a_coords);
535 
536  // :TODO: border styles?
537  if ($a_top) {
538  $style->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
539  }
540  if ($a_right) {
541  $style->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
542  }
543  if ($a_bottom) {
544  $style->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
545  }
546  if ($a_left) {
547  $style->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
548  }
549  }
$style
Definition: example_012.php:70
Add a hyperlink to another cell on a different worksheet within the workbook

◆ 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
PHPExcel_Exception

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

References prepareValue(), setDateFormat(), PHPExcel_Cell_DataType\TYPE_NUMERIC, PHPExcel_Cell_DataType\TYPE_STRING, and workbook.

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

277  {
278  if (!is_null($a_datatype)) {
279  $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
280  $a_col,
281  $a_row,
282  $this->prepareValue($a_value),
283  $a_datatype
284  );
285  } elseif ($a_value instanceof ilDateTime) {
286  $cell = $this->workbook->getActiveSheet()->setCellValueByColumnAndRow(
287  $a_col,
288  $a_row,
289  $this->prepareValue($a_value),
290  true
291  );
292  $this->setDateFormat($cell, $a_value);
293  } elseif (is_numeric($a_value)) {
294  $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
295  $a_col,
296  $a_row,
297  $this->prepareValue($a_value),
299  false
300  );
301  } else {
302  $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
303  $a_col,
304  $a_row,
305  $this->prepareValue($a_value),
307  false
308  );
309  }
310  }
Add a hyperlink to another cell on a different worksheet within the workbook
setDateFormat(PHPExcel_Cell $a_cell, $a_value)
Set date format.
Date and time handling
prepareValue($a_value)
Prepare value for cell.
+ 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 319 of file class.ilExcel.php.

References $cols, prepareValue(), and workbook.

320  {
321  foreach ($a_values as $row_idx => $cols) {
322  if (is_array($cols)) {
323  foreach ($cols as $col_idx => $col_value) {
324  $a_values[$row_idx][$col_idx] = $this->prepareValue($col_value);
325  }
326  } else {
327  $a_values[$row_idx] = $this->prepareValue($cols);
328  }
329  }
330 
331  $this->workbook->getActiveSheet()->fromArray($a_values, $a_null_value, $a_top_left);
332  }
Add a hyperlink to another cell on a different worksheet within the workbook
$cols
Definition: xhr_table.php:11
prepareValue($a_value)
Prepare value for cell.
+ 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

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

References prepareValue(), setDateFormat(), PHPExcel_Cell_DataType\TYPE_NUMERIC, PHPExcel_Cell_DataType\TYPE_STRING, and workbook.

243  {
244  if ($a_value instanceof ilDateTime) {
245  $cell = $this->workbook->getActiveSheet()->setCellValue(
246  $a_coords,
247  $this->prepareValue($a_value),
248  true
249  );
250  $this->setDateFormat($cell, $a_value);
251  } elseif (is_numeric($a_value)) {
252  $this->workbook->getActiveSheet()->setCellValueExplicit(
253  $a_coords,
254  $this->prepareValue($a_value),
256  false
257  );
258  } else {
259  $this->workbook->getActiveSheet()->setCellValueExplicit(
260  $a_coords,
261  $this->prepareValue($a_value),
263  false
264  );
265  }
266  }
Add a hyperlink to another cell on a different worksheet within the workbook
setDateFormat(PHPExcel_Cell $a_cell, $a_value)
Set date format.
Date and time handling
prepareValue($a_value)
Prepare value for cell.
+ 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 505 of file class.ilExcel.php.

References array, PHPExcel_Style_Fill\FILL_SOLID, and workbook.

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

506  {
507  $opts = array(
508  'fill' => array(
510  'color' => array('rgb' => $a_background)
511  )
512  );
513 
514  if ($a_font) {
515  $opts['font'] = array(
516  'color' => array('rgb' => $a_font)
517  );
518  }
519 
520  $this->workbook->getActiveSheet()->getStyle($a_coords)->applyFromArray($opts);
521  }
Add a hyperlink to another cell on a different worksheet within the workbook
Create styles array
The data for the language used.
const FILL_SOLID
Definition: Fill.php:40
+ Here is the caller graph for this function:

◆ setDateFormat()

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

Set date format.

Parameters
PHPExcel_Cell$a_cell
mixed$a_value

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

References PHPExcel_Cell\getStyle().

Referenced by setCell(), and setCellByCoordinates().

226  {
227  if ($a_value instanceof ilDate) {
228  // :TODO: i18n?
229  $a_cell->getStyle()->getNumberFormat()->setFormatCode("dd.mm.yyyy");
230  } elseif ($a_value instanceof ilDateTime) {
231  // :TODO: i18n?
232  $a_cell->getStyle()->getNumberFormat()->setFormatCode("dd.mm.yyyy hh:mm:ss");
233  }
234  }
getStyle()
Get cell style.
Definition: Cell.php:536
Class for single dates.
Date and time handling
+ 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 79 of file class.ilExcel.php.

References format, and getValidFormats().

Referenced by __construct().

80  {
81  if (in_array($a_format, $this->getValidFormats())) {
82  $this->format = $a_format;
83  }
84  }
getValidFormats()
Get valid file formats.
Write to Excel2007 format
+ 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 384 of file class.ilExcel.php.

References $worksheet, and workbook.

Referenced by prepareStorage().

385  {
386  // this may change the active sheet
387  foreach ($this->workbook->getWorksheetIterator() as $worksheet) {
388  $this->workbook->setActiveSheetIndex($this->workbook->getIndex($worksheet));
389  $sheet = $this->workbook->getActiveSheet();
390  $cellIterator = $sheet->getRowIterator()->current()->getCellIterator();
391  $cellIterator->setIterateOnlyExistingCells(true);
392  foreach ($cellIterator as $cell) {
393  $sheet->getColumnDimension($cell->getColumn())->setAutoSize(true);
394  }
395  }
396  }
$worksheet
Add a hyperlink to another cell on a different worksheet within the workbook
+ 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 462 of file class.ilExcel.php.

References PHPExcel_IOFactory\createWriter(), format, prepareStorage(), and workbook.

463  {
464  $a_file = $this->prepareStorage($a_file);
465 
466  $writer = PHPExcel_IOFactory::createWriter($this->workbook, $this->format);
467  $writer->save($a_file);
468  }
Add a hyperlink to another cell on a different worksheet within the workbook
prepareStorage($a_file_name)
Prepare workbook for storage/delivery.
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132
Write to Excel2007 format
+ Here is the call graph for this function:

◆ writeToTmpFile()

ilExcel::writeToTmpFile ( )
Returns
string
Exceptions

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

References $filename, PHPExcel_IOFactory\createWriter(), format, ilUtil\ilTempnam(), and workbook.

476  {
477  $writer = PHPExcel_IOFactory::createWriter($this->workbook, $this->format);
479  $writer->save($filename);
480 
481  return $filename;
482  }
Add a hyperlink to another cell on a different worksheet within the workbook
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
Write to Excel2007 format
+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilExcel::$lng
protected

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

Referenced by prepareBooleanValue(), and prepareValue().

◆ $type

ilExcel::$type
protected

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

◆ $workbook

ilExcel::$workbook
protected

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

◆ FORMAT_BIFF

const ilExcel::FORMAT_BIFF = "Excel5"

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

◆ FORMAT_XML

const ilExcel::FORMAT_XML = "Excel2007"

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


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