ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilExcelXMLAdapter Class Reference

Adapter class to provide Excel writing support for ILIAS. More...

+ Inheritance diagram for ilExcelXMLAdapter:
+ Collaboration diagram for ilExcelXMLAdapter:

Public Member Functions

 __construct ()
 save ()
 deliver ($outputfilename)
 getWorksheetCount ()
 setActiveWorksheet ($index=0)
 setWorksheetTitle ($title)
 setColumnWidth ($columnindex, $width)
 addWorksheet ($title="")
 setCellValue ($row, $col, $value, $format=CELL_FORMAT_NONE)
 getFileExtension ()

Data Fields

 $objPHPExcel

Protected Member Functions

 formatCellTitle ()
 formatCellCenter ()
 formatCellBold ()
 formatCellPercent ()

Private Member Functions

 getCellTitle ($index)

Detailed Description

Adapter class to provide Excel writing support for ILIAS.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

Definition at line 13 of file class.ilExcelXMLAdapter.php.

Constructor & Destructor Documentation

ilExcelXMLAdapter::__construct ( )

PHPExcel

PHPExcel_Writer_Excel2007

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

References PHPExcel_CachedObjectStorageFactory\cache_in_memory_gzip, and PHPExcel_Settings\setCacheStorageMethod().

{
$worksheets = array();
include_once './Services/Excel/PHPExcel/1.7.6/Classes/PHPExcel.php';
include_once './Services/Excel/PHPExcel/1.7.6/Classes/PHPExcel/Writer/Excel2007.php';
// set cache to temp dir to prevent memory exhaustion
$cacheSettings = array();
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
// Create new PHPExcel object
$this->objPHPExcel = new PHPExcel();
// Set properties
$this->objPHPExcel->getProperties()->setCreator("ILIAS Open Source");
$this->objPHPExcel->getProperties()->setLastModifiedBy("ILIAS Open Source");
$this->objPHPExcel->getProperties()->setTitle($this->strFormKey);
$this->objPHPExcel->getProperties()->setSubject($this->strFormKey);
$this->objPHPExcel->getProperties()->setDescription($this->strFormKey);
$this->objPHPExcel->getProperties()->setKeywords("Office 2007 ILIAS Open Source");
$this->objPHPExcel->getProperties()->setCategory("wcms data storage");
$this->objPHPExcel->setActiveSheetIndex(0);
}

+ Here is the call graph for this function:

Member Function Documentation

ilExcelXMLAdapter::addWorksheet (   $title = "")

Reimplemented from ilExcelAdapter.

Definition at line 104 of file class.ilExcelXMLAdapter.php.

References $title.

{
$objWorksheet = $this->objPHPExcel->createSheet();
try
{
$objWorksheet->setTitle(substr($title, 0, 31));
}
catch (Exception $e)
{
}
return $objWorksheet;
}
ilExcelXMLAdapter::deliver (   $outputfilename)

Reimplemented from ilExcelAdapter.

Definition at line 56 of file class.ilExcelXMLAdapter.php.

References exit, and save().

{
$tempname = $this->save();
header('Content-Type: appplication/excel');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: attachment; filename="' . $outputfilename . '"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Expires: 0');
print file_get_contents($tempname);
unlink($tempname);
}

+ Here is the call graph for this function:

ilExcelXMLAdapter::formatCellBold ( )
protected

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

Referenced by setCellValue().

{
return array(
'font' => array(
'bold' => true,
'color' => array(
'argb' => 'FF000000'
)
)
);
}

+ Here is the caller graph for this function:

ilExcelXMLAdapter::formatCellCenter ( )
protected

Definition at line 169 of file class.ilExcelXMLAdapter.php.

References PHPExcel_Style_Alignment\HORIZONTAL_CENTER.

Referenced by setCellValue().

{
return array(
'font' => array(
'bold' => false,
'color' => array(
'argb' => 'FF000000'
)
),
'alignment' => array(
)
);
}

+ Here is the caller graph for this function:

ilExcelXMLAdapter::formatCellPercent ( )
protected

Definition at line 196 of file class.ilExcelXMLAdapter.php.

References PHPExcel_Style_Alignment\HORIZONTAL_CENTER.

{
return array(
'font' => array(
'bold' => true,
'color' => array(
'argb' => '00000080'
)
),
'alignment' => array(
)
);
}
ilExcelXMLAdapter::formatCellTitle ( )
protected

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

References PHPExcel_Style_Fill\FILL_SOLID, and PHPExcel_Style_Alignment\HORIZONTAL_CENTER.

Referenced by setCellValue().

{
return array(
'font' => array(
'bold' => true,
'color' => array(
'argb' => 'FF000000'
)
),
'fill' => array(
'color' => array(
'argb'=>'80AAAAAA'
),
),
'alignment' => array(
)
);
}

+ Here is the caller graph for this function:

ilExcelXMLAdapter::getCellTitle (   $index)
private

Definition at line 216 of file class.ilExcelXMLAdapter.php.

Referenced by setCellValue(), and setColumnWidth().

{
if ($index < 26) {
return chr(65 + $index);
} elseif ($index < 702) {
return chr(64 + ($index / 26)).chr(65 + $index % 26);
}
return chr(64 + (($index - 26) / 676)).chr(65 + ((($index - 26) % 676) / 26)).chr(65 + $index % 26);
}

+ Here is the caller graph for this function:

ilExcelXMLAdapter::getFileExtension ( )

Reimplemented from ilExcelAdapter.

Definition at line 211 of file class.ilExcelXMLAdapter.php.

{
return "xlsx";
}
ilExcelXMLAdapter::getWorksheetCount ( )

Reimplemented from ilExcelAdapter.

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

{
return $this->objPHPExcel->getSheetCount();
}
ilExcelXMLAdapter::save ( )

Reimplemented from ilExcelAdapter.

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

References ilUtil\ilTempnam().

Referenced by deliver().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$objWriter = new PHPExcel_Writer_Excel2007($this->objPHPExcel);
$tempname = ilUtil::ilTempnam() .".xlsx";
$objWriter->save($tempname);
return $tempname;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilExcelXMLAdapter::setActiveWorksheet (   $index = 0)

Reimplemented from ilExcelAdapter.

Definition at line 75 of file class.ilExcelXMLAdapter.php.

{
$this->objPHPExcel->setActiveSheetIndex($index);
}
ilExcelXMLAdapter::setCellValue (   $row,
  $col,
  $value,
  $format = CELL_FORMAT_NONE 
)

Reimplemented from ilExcelAdapter.

Definition at line 118 of file class.ilExcelXMLAdapter.php.

References CELL_FORMAT_BOLD, CELL_FORMAT_CENTER, CELL_FORMAT_DATETIME, CELL_FORMAT_MINUTES, CELL_FORMAT_NONE, CELL_FORMAT_PERCENT, CELL_FORMAT_TITLE, PHPExcel_Style_NumberFormat\FORMAT_DATE_DATETIME, PHPExcel_Style_NumberFormat\FORMAT_PERCENTAGE, formatCellBold(), formatCellCenter(), formatCellTitle(), and getCellTitle().

{
$cell = $this->getCellTitle($col).($row+1);
$this->objPHPExcel->getActiveSheet()->setCellValue($cell, $value);
switch ($format)
{
$this->objPHPExcel->getActiveSheet()->getStyle($cell)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DATETIME);
break;
$this->objPHPExcel->getActiveSheet()->getStyle($cell)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE);
break;
$this->objPHPExcel->getActiveSheet()->getStyle($cell)->getNumberFormat()->setFormatCode('hh:mm');
break;
$this->objPHPExcel->getActiveSheet()->getStyle($cell)->applyFromArray($this->formatCellTitle());
break;
$this->objPHPExcel->getActiveSheet()->getStyle($cell)->applyFromArray($this->formatCellCenter());
break;
$this->objPHPExcel->getActiveSheet()->getStyle($cell)->applyFromArray($this->formatCellBold());
break;
default:
break;
}
}

+ Here is the call graph for this function:

ilExcelXMLAdapter::setColumnWidth (   $columnindex,
  $width 
)

Reimplemented from ilExcelAdapter.

Definition at line 92 of file class.ilExcelXMLAdapter.php.

References getCellTitle().

{
if (strcmp($width, 'auto') == 0)
{
$this->objPHPExcel->getActiveSheet()->getColumnDimension($this->getCellTitle($columnindex))->setAutoSize(true);
}
else
{
$this->objPHPExcel->getActiveSheet()->getColumnDimension($this->getCellTitle($columnindex))->setWidth($width);
}
}

+ Here is the call graph for this function:

ilExcelXMLAdapter::setWorksheetTitle (   $title)

Reimplemented from ilExcelAdapter.

Definition at line 80 of file class.ilExcelXMLAdapter.php.

References $title.

{
try
{
$this->objPHPExcel->getActiveSheet()->setTitle(substr($title, 0, 31));
}
catch (Exception $e)
{
}
}

Field Documentation

ilExcelXMLAdapter::$objPHPExcel

Definition at line 15 of file class.ilExcelXMLAdapter.php.


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