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

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

+ Inheritance diagram for ilExcelXLSAdapter:
+ Collaboration diagram for ilExcelXLSAdapter:

Public Member Functions

 __construct ()
 save ()
 deliver ($outputfilename)
 getWorksheetCount ()
 setActiveWorksheet ($index=0)
 setWorksheetTitle ($title)
 addWorksheet ($title="")
 setColumnWidth ($columnindex, $width)
 setCellValue ($row, $col, $value, $format=CELL_FORMAT_NONE)
 getFileExtension ()
 convertToWindowsCharset ($string)
 Zusatzfunktion: Umlaute in Excel Tabellenblätter darstellen.

Data Fields

 $adapter
 $workbook
 $excelfile
 $activesheet
 $format_bold
 $format_percent
 $format_datetime
 $format_minutes
 $format_title
 $format_center

Protected Member Functions

 getActiveSheet ()

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.ilExcelXLSAdapter.php.

Constructor & Destructor Documentation

ilExcelXLSAdapter::__construct ( )

Definition at line 26 of file class.ilExcelXLSAdapter.php.

References addWorksheet(), and ilUtil\ilTempnam().

{
$worksheets = array();
$this->excelfile = ilUtil::ilTempnam();
include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
$this->adapter = new ilExcelWriterAdapter($this->excelfile, FALSE);
$this->workbook = $this->adapter->getWorkbook();
$this->workbook->setVersion(8); // Use Excel97/2000 Format
$this->format_bold =& $this->workbook->addFormat();
$this->format_bold->setBold();
$this->format_center =& $this->workbook->addFormat();
$this->format_center->setColor('black');
$this->format_center->setAlign('center');
$this->format_percent =& $this->workbook->addFormat();
$this->format_percent->setNumFormat("0.00%");
$this->format_datetime =& $this->workbook->addFormat();
$this->format_datetime->setNumFormat("DD/MM/YYYY hh:mm:ss");
$this->format_minutes =& $this->workbook->addFormat();
$this->format_minutes->setNumFormat("mm:ss");
$this->format_title =& $this->workbook->addFormat();
$this->format_title->setBold();
$this->format_title->setColor('black');
$this->format_title->setPattern(1);
$this->format_title->setFgColor('silver');
$this->addWorksheet('table 1');
}

+ Here is the call graph for this function:

Member Function Documentation

ilExcelXLSAdapter::addWorksheet (   $title = "")

Reimplemented from ilExcelAdapter.

Definition at line 91 of file class.ilExcelXLSAdapter.php.

References $title, convertToWindowsCharset(), and getWorksheetCount().

Referenced by __construct().

{
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
if (strlen($title))
{
$objWorksheet = $this->workbook->addWorksheet($this->convertToWindowsCharset($title));
}
else
{
$objWorksheet = $this->workbook->addWorksheet();
}
$this->activesheet = $this->getWorksheetCount()-1;
return $objWorksheet;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilExcelXLSAdapter::convertToWindowsCharset (   $string)

Zusatzfunktion: Umlaute in Excel Tabellenblätter darstellen.

Definition at line 149 of file class.ilExcelXLSAdapter.php.

Referenced by addWorksheet(), setCellValue(), and setWorksheetTitle().

{
$charset = mb_detect_encoding(
$string,
"UTF-8, ISO-8859-1, ISO-8859-15",
true
);
$string = mb_convert_encoding($string, "Windows-1252", $charset);
return $string;
}

+ Here is the caller graph for this function:

ilExcelXLSAdapter::deliver (   $outputfilename)

Reimplemented from ilExcelAdapter.

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

References ilUtil\deliverFile(), and exit.

{
$this->workbook->close();
ilUtil::deliverFile($this->excelfile, $outputfilename, "application/vnd.ms-excel", false, true);
}

+ Here is the call graph for this function:

ilExcelXLSAdapter::getActiveSheet ( )
protected

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

References $activesheet.

Referenced by setCellValue(), and setWorksheetTitle().

{
$sheets = $this->workbook->worksheets();
return $sheets[$this->activesheet];
}

+ Here is the caller graph for this function:

ilExcelXLSAdapter::getFileExtension ( )

Reimplemented from ilExcelAdapter.

Definition at line 140 of file class.ilExcelXLSAdapter.php.

{
return "xls";
}
ilExcelXLSAdapter::getWorksheetCount ( )

Reimplemented from ilExcelAdapter.

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

Referenced by addWorksheet().

{
return count($this->workbook->worksheets());
}

+ Here is the caller graph for this function:

ilExcelXLSAdapter::save ( )

Reimplemented from ilExcelAdapter.

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

References $excelfile.

{
$this->workbook->close();
}
ilExcelXLSAdapter::setActiveWorksheet (   $index = 0)

Reimplemented from ilExcelAdapter.

Definition at line 74 of file class.ilExcelXLSAdapter.php.

{
$this->activesheet = $index;
}
ilExcelXLSAdapter::setCellValue (   $row,
  $col,
  $value,
  $format = CELL_FORMAT_NONE 
)

Reimplemented from ilExcelAdapter.

Definition at line 110 of file class.ilExcelXLSAdapter.php.

References $row, CELL_FORMAT_BOLD, CELL_FORMAT_CENTER, CELL_FORMAT_DATETIME, CELL_FORMAT_MINUTES, CELL_FORMAT_NONE, CELL_FORMAT_PERCENT, CELL_FORMAT_TITLE, convertToWindowsCharset(), and getActiveSheet().

{
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
switch ($format)
{
$this->getActiveSheet()->write($row, $col, $value, $this->format_datetime);
break;
$this->getActiveSheet()->write($row, $col, $value, $this->format_percent);
break;
$this->getActiveSheet()->write($row, $col, $value, $this->format_minutes);
break;
$this->getActiveSheet()->write($row, $col, $value, $this->format_center);
break;
$this->getActiveSheet()->writeString($row, $col, $this->convertToWindowsCharset($value), $this->format_title);
break;
$this->getActiveSheet()->writeString($row, $col, $this->convertToWindowsCharset($value), $this->format_bold);
break;
default:
$this->getActiveSheet()->writeString($row, $col, $this->convertToWindowsCharset($value));
break;
}
}

+ Here is the call graph for this function:

ilExcelXLSAdapter::setColumnWidth (   $columnindex,
  $width 
)

Reimplemented from ilExcelAdapter.

Definition at line 106 of file class.ilExcelXLSAdapter.php.

{
}
ilExcelXLSAdapter::setWorksheetTitle (   $title)

Reimplemented from ilExcelAdapter.

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

References $title, convertToWindowsCharset(), and getActiveSheet().

{
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
$this->getActiveSheet()->name = substr($this->convertToWindowsCharset($title), 0, 31);
}

+ Here is the call graph for this function:

Field Documentation

ilExcelXLSAdapter::$activesheet

Definition at line 18 of file class.ilExcelXLSAdapter.php.

Referenced by getActiveSheet().

ilExcelXLSAdapter::$adapter

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

ilExcelXLSAdapter::$excelfile

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

Referenced by save().

ilExcelXLSAdapter::$format_bold

Definition at line 19 of file class.ilExcelXLSAdapter.php.

ilExcelXLSAdapter::$format_center

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

ilExcelXLSAdapter::$format_datetime

Definition at line 21 of file class.ilExcelXLSAdapter.php.

ilExcelXLSAdapter::$format_minutes

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

ilExcelXLSAdapter::$format_percent

Definition at line 20 of file class.ilExcelXLSAdapter.php.

ilExcelXLSAdapter::$format_title

Definition at line 23 of file class.ilExcelXLSAdapter.php.

ilExcelXLSAdapter::$workbook

Definition at line 16 of file class.ilExcelXLSAdapter.php.


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