ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
SimpleExcel\SimpleExcel Class Reference
+ Collaboration diagram for SimpleExcel\SimpleExcel:

Public Member Functions

 __construct ($filetype='XML')
 SimpleExcel constructor method. More...
 
 constructParser ($filetype)
 Construct a SimpleExcel Parser. More...
 
 constructWriter ($filetype)
 Construct a SimpleExcel Writer. More...
 
 convertTo ($filetype)
 Change writer type to convert to another format. More...
 

Data Fields

 $parser
 
 $writer
 

Protected Attributes

 $validParserTypes = array('XML', 'CSV', 'TSV', 'HTML', 'JSON')
 
 $validWriterTypes = array('XML', 'CSV', 'TSV', 'HTML', 'JSON')
 

Detailed Description

Definition at line 53 of file SimpleExcel.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleExcel\SimpleExcel::__construct (   $filetype = 'XML')

SimpleExcel constructor method.

Parameters
string$filetypeSet the filetype of the file which will be parsed (XML/CSV/TSV/HTML/JSON)
Returns
void

Definition at line 80 of file SimpleExcel.php.

80  {
81  $this->constructParser($filetype);
82  $this->constructWriter($filetype);
83  }
constructWriter($filetype)
Construct a SimpleExcel Writer.
constructParser($filetype)
Construct a SimpleExcel Parser.
Definition: SimpleExcel.php:91

Member Function Documentation

◆ constructParser()

SimpleExcel\SimpleExcel::constructParser (   $filetype)

Construct a SimpleExcel Parser.

Parameters
string$filetypeSet the filetype of the file which will be parsed (XML/CSV/TSV/HTML/JSON)
Exceptions
ExceptionIf filetype is neither XML/CSV/TSV/HTML/JSON

Definition at line 91 of file SimpleExcel.php.

References SimpleExcel\Exception\SimpleExcelException\FILETYPE_NOT_SUPPORTED.

91  {
92  $filetype = strtoupper($filetype);
93  if(!in_array($filetype, $this->validParserTypes)){
94  throw new \Exception('Filetype '.$filetype.' is not supported', SimpleExcelException::FILETYPE_NOT_SUPPORTED);
95  }
96  $parser_class = 'SimpleExcel\\Parser\\'.$filetype.'Parser';
97  $this->parser = new $parser_class();
98  }

◆ constructWriter()

SimpleExcel\SimpleExcel::constructWriter (   $filetype)

Construct a SimpleExcel Writer.

Parameters
string$filetypeSet the filetype of the file which will be written (XML/CSV/TSV/HTML/JSON)
Returns
bool
Exceptions
ExceptionIf filetype is neither XML/CSV/TSV/HTML/JSON

Definition at line 107 of file SimpleExcel.php.

References SimpleExcel\Exception\SimpleExcelException\FILETYPE_NOT_SUPPORTED.

107  {
108  $filetype = strtoupper($filetype);
109 
110  if(!in_array($filetype, $this->validWriterTypes)){
111  throw new \Exception('Filetype '.$filetype.' is not supported', SimpleExcelException::FILETYPE_NOT_SUPPORTED);
112  }
113  $writer_class = 'SimpleExcel\\Writer\\'.$filetype.'Writer';
114  $this->writer = new $writer_class();
115  }

◆ convertTo()

SimpleExcel\SimpleExcel::convertTo (   $filetype)

Change writer type to convert to another format.

Parameters
string$filetypeSet the filetype of the file which will be written (XML/CSV/TSV/HTML/JSON)

Definition at line 122 of file SimpleExcel.php.

122  {
123  $this->constructWriter($filetype);
124  $this->writer->setData($this->parser->getField());
125  }
constructWriter($filetype)
Construct a SimpleExcel Writer.

Field Documentation

◆ $parser

SimpleExcel\SimpleExcel::$parser

Definition at line 59 of file SimpleExcel.php.

◆ $validParserTypes

SimpleExcel\SimpleExcel::$validParserTypes = array('XML', 'CSV', 'TSV', 'HTML', 'JSON')
protected

Definition at line 71 of file SimpleExcel.php.

◆ $validWriterTypes

SimpleExcel\SimpleExcel::$validWriterTypes = array('XML', 'CSV', 'TSV', 'HTML', 'JSON')
protected

Definition at line 72 of file SimpleExcel.php.

◆ $writer

SimpleExcel\SimpleExcel::$writer

Definition at line 65 of file SimpleExcel.php.


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