ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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)
 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

 $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 32 of file class.ilExcel.php.

References setFormat(), and workbook.

33  {
34  $this->setFormat(self::FORMAT_XML);
35  $this->workbook = new PHPExcel();
36  $this->workbook->removeSheetByIndex(0);
37  }
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 90 of file class.ilExcel.php.

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

Referenced by ilSurveyEvaluationGUI\exportResultsDetailsExcel().

91  {
92  // see PHPExcel_Worksheet::$_invalidCharacters;
93  #20749
94  $invalid = array('*', ':', '/', '\\', '?', '[', ']', '\'-','\'');
95 
96  $a_name = str_replace($invalid, "", $a_name);
97 
98  // #19056 - phpExcel only allows 31 chars
99  // see https://github.com/PHPOffice/PHPExcel/issues/79
100  $a_name = ilUtil::shortenText($a_name, 31);
101 
102  $sheet = new PHPExcel_Worksheet($this->workbook, $a_name);
103  $this->workbook->addSheet($sheet);
104  $new_index = $this->workbook->getSheetCount()-1;
105 
106  if((bool)$a_activate)
107  {
108  $this->setActiveSheet($new_index);
109  }
110 
111  return $new_index;
112  }
setActiveSheet($a_index)
Set active sheet.
Add a hyperlink to another cell on a different worksheet within the workbook
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
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 351 of file class.ilExcel.php.

References workbook.

351  {
352  return $this->workbook->getActiveSheet()->getCellByColumnAndRow($a_col, $a_row)->getValue();
353  }
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 381 of file class.ilExcel.php.

References PHPExcel_Cell\stringFromColumnIndex().

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

382  {
384  }
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 371 of file class.ilExcel.php.

References PHPExcel_Cell\columnIndexFromString(), and workbook.

371  {
372  return PHPExcel_Cell::columnIndexFromString($this->workbook->getActiveSheet()->getHighestDataColumn());
373  }
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 573 of file class.ilExcel.php.

References PHPExcel_Cell\stringFromColumnIndex().

Referenced by ilSurveyEvaluationGUI\exportResultsDetailsExcel().

574  {
575  $columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
576  return $columnLetter . $pRow;
577  }
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 361 of file class.ilExcel.php.

References workbook.

361  {
362  return $this->workbook->getActiveSheet()->toArray();
363  }
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 130 of file class.ilExcel.php.

References workbook.

130  {
131  return $this->workbook->getSheetCount();
132  }
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 140 of file class.ilExcel.php.

References workbook.

140  {
141  return $this->workbook->getActiveSheet()->getTitle();
142  }
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 60 of file class.ilExcel.php.

References array.

Referenced by setFormat().

61  {
62  return array(self::FORMAT_XML, self::FORMAT_BIFF);
63  }
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 47 of file class.ilExcel.php.

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

47  {
49  }
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 200 of file class.ilExcel.php.

References $lng.

Referenced by prepareValue().

201  {
202  global $lng;
203 
204  return $a_value ? $lng->txt('yes') : $lng->txt('no');
205  }
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ prepareDateValue()

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

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

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

Referenced by prepareValue().

181  {
182  switch(true)
183  {
184  case $a_value instanceof ilDate:
185  $a_value = PHPExcel_Shared_Date::stringToExcel($a_value->get(IL_CAL_DATE));
186  break;
187 
188  default:
190  break;
191  }
192 
193  return $a_value;
194  }
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 412 of file class.ilExcel.php.

References format, setGlobalAutoSize(), and workbook.

Referenced by sendToClient(), and writeToFile().

413  {
414  $this->setGlobalAutoSize();
415  $this->workbook->setActiveSheetIndex(0);
416 
417  switch($this->format)
418  {
419  case self::FORMAT_BIFF:
420  if(!stristr($a_file_name, ".xls"))
421  {
422  $a_file_name .= ".xls";
423  }
424  break;
425 
426  case self::FORMAT_XML:
427  if(!stristr($a_file_name, ".xlsx"))
428  {
429  $a_file_name .= ".xlsx";
430  }
431  break;
432  }
433 
434  return $a_file_name;
435  }
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 211 of file class.ilExcel.php.

Referenced by prepareValue().

212  {
213  return strip_tags($a_value); // #14542
214  }
+ 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 155 of file class.ilExcel.php.

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

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

156  {
157  global $lng;
158 
159  // :TODO: does this make sense?
160  if(is_bool($a_value))
161  {
162  $a_value = $this->prepareBooleanValue($a_value);
163  }
164  else if($a_value instanceof ilDateTime)
165  {
166  $a_value = $this->prepareDateValue($a_value);
167  }
168  else if(is_string($a_value))
169  {
170  $a_value = $this->prepareString($a_value);
171  }
172 
173  return $a_value;
174  }
prepareString($a_value)
prepareBooleanValue($a_value)
Date and time handling
prepareDateValue(ilDateTime $a_value)
global $lng
Definition: privfeed.php:17
+ 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 442 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\DIRECT_PHP_OUTPUT, format, prepareStorage(), and workbook.

443  {
444  require_once('./Services/FileDelivery/classes/class.ilPHPOutputDelivery.php');
445 
446  $a_file_name = $this->prepareStorage($a_file_name);
447  switch ($this->format) {
448  case self::FORMAT_BIFF:
450  break;
451 
452  case self::FORMAT_XML:
454  break;
455  default:
457  break;
458  }
459  $ilPHPOutputDelivery = new ilPHPOutputDelivery();
460  $ilPHPOutputDelivery->start($a_file_name, $a_mime_type);
461 
462  $writer = PHPExcel_IOFactory::createWriter($this->workbook, $this->format);
463  $writer->save(ilFileDelivery::DIRECT_PHP_OUTPUT);
464 
465  $ilPHPOutputDelivery->stop();
466  }
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
Class ilPHPOutputDelivery.
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 119 of file class.ilExcel.php.

References workbook.

Referenced by addSheet().

120  {
121  $this->workbook->setActiveSheetIndex($a_index);
122  }
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 503 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().

504  {
505  $this->workbook->getActiveSheet()->getStyle($a_coords)->getFont()->setBold(true);
506  }
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 543 of file class.ilExcel.php.

References $style, PHPExcel_Style_Border\BORDER_THIN, and workbook.

544  {
545  $style = $this->workbook->getActiveSheet()->getStyle($a_coords);
546 
547  // :TODO: border styles?
548  if($a_top)
549  {
550  $style->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
551  }
552  if($a_right)
553  {
554  $style->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
555  }
556  if($a_bottom)
557  {
558  $style->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
559  }
560  if($a_left)
561  {
562  $style->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
563  }
564  }
$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 
)

Set cell value.

Parameters
int$a_row
int$a_col
mixed$a_value

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

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

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

282  {
283  if($a_value instanceof ilDateTime)
284  {
285  $cell = $this->workbook->getActiveSheet()->setCellValueByColumnAndRow(
286  $a_col,
287  $a_row,
288  $this->prepareValue($a_value),
289  true
290  );
291  $this->setDateFormat($cell, $a_value);
292  }
293  elseif(is_numeric($a_value))
294  {
295  $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
296  $a_col,
297  $a_row,
298  $this->prepareValue($a_value),
300  false
301  );
302  }
303  else
304  {
305  $this->workbook->getActiveSheet()->setCellValueExplicitByColumnAndRow(
306  $a_col,
307  $a_row,
308  $this->prepareValue($a_value),
310  false
311  );
312  }
313  }
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 322 of file class.ilExcel.php.

References prepareValue(), and workbook.

323  {
324  foreach($a_values as $row_idx => $cols)
325  {
326  if(is_array($cols))
327  {
328  foreach($cols as $col_idx => $col_value)
329  {
330  $a_values[$row_idx][$col_idx] = $this->prepareValue($col_value);
331  }
332  }
333  else
334  {
335  $a_values[$row_idx] = $this->prepareValue($cols);
336  }
337  }
338 
339  $this->workbook->getActiveSheet()->fromArray($a_values, $a_null_value, $a_top_left);
340  }
Add a hyperlink to another cell on a different worksheet within the workbook
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  {
246  $cell = $this->workbook->getActiveSheet()->setCellValue(
247  $a_coords,
248  $this->prepareValue($a_value),
249  true
250  );
251  $this->setDateFormat($cell, $a_value);
252  }
253  elseif(is_numeric($a_value))
254  {
255  $this->workbook->getActiveSheet()->setCellValueExplicit(
256  $a_coords,
257  $this->prepareValue($a_value),
259  false
260  );
261  }
262  else
263  {
264  $this->workbook->getActiveSheet()->setCellValueExplicit(
265  $a_coords,
266  $this->prepareValue($a_value),
268  false
269  );
270  }
271 
272  }
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 515 of file class.ilExcel.php.

References array, PHPExcel_Style_Fill\FILL_SOLID, and workbook.

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

516  {
517  $opts = array(
518  'fill' => array(
520  'color' => array('rgb' => $a_background)
521  )
522  );
523 
524  if($a_font)
525  {
526  $opts['font'] = array(
527  'color' => array('rgb' => $a_font)
528  );
529  }
530 
531  $this->workbook->getActiveSheet()->getStyle($a_coords)->applyFromArray($opts);
532  }
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 222 of file class.ilExcel.php.

References PHPExcel_Cell\getStyle().

Referenced by setCell(), and setCellByCoordinates().

223  {
224  if($a_value instanceof ilDate)
225  {
226  // :TODO: i18n?
227  $a_cell->getStyle()->getNumberFormat()->setFormatCode("dd.mm.yyyy");
228  }
229  else if($a_value instanceof ilDateTime)
230  {
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 70 of file class.ilExcel.php.

References format, and getValidFormats().

Referenced by __construct().

71  {
72  if(in_array($a_format, $this->getValidFormats()))
73  {
74  $this->format = $a_format;
75  }
76  }
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 389 of file class.ilExcel.php.

References $worksheet, and workbook.

Referenced by prepareStorage().

390  {
391  // this may change the active sheet
392  foreach($this->workbook->getWorksheetIterator() as $worksheet)
393  {
394  $this->workbook->setActiveSheetIndex($this->workbook->getIndex($worksheet));
395  $sheet = $this->workbook->getActiveSheet();
396  $cellIterator = $sheet->getRowIterator()->current()->getCellIterator();
397  $cellIterator->setIterateOnlyExistingCells(true);
398  foreach($cellIterator as $cell)
399  {
400  $sheet->getColumnDimension($cell->getColumn())->setAutoSize(true);
401  }
402  }
403  }
$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 473 of file class.ilExcel.php.

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

474  {
475  $a_file = $this->prepareStorage($a_file);
476 
477  $writer = PHPExcel_IOFactory::createWriter($this->workbook, $this->format);
478  $writer->save($a_file);
479  }
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 486 of file class.ilExcel.php.

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

486  {
487  $writer = PHPExcel_IOFactory::createWriter($this->workbook, $this->format);
489  $writer->save($filename);
490 
491  return $filename;
492  }
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

◆ $type

ilExcel::$type
protected

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

◆ $workbook

ilExcel::$workbook
protected

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

◆ FORMAT_BIFF

const ilExcel::FORMAT_BIFF = "Excel5"

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

◆ FORMAT_XML

const ilExcel::FORMAT_XML = "Excel2007"

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


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