ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_IOFactory Class Reference
+ Collaboration diagram for PHPExcel_IOFactory:

Static Public Member Functions

static getSearchLocations ()
 Get search locations.
static setSearchLocations ($value)
 Set search locations.
static addSearchLocation ($type= '', $location= '', $classname= '')
 Add search location.
static createWriter (PHPExcel $phpExcel, $writerType= '')
 Create PHPExcel_Writer_IWriter.
static createReader ($readerType= '')
 Create PHPExcel_Reader_IReader.
static load ($pFilename)
 Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution.
static identify ($pFilename)
 Identify file type using automatic PHPExcel_Reader_IReader resolution.
static createReaderForFile ($pFilename)
 Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution.

Private Member Functions

 __construct ()
 Private constructor for PHPExcel_IOFactory.

Static Private Attributes

static $_searchLocations
static $_autoResolveClasses

Detailed Description

Definition at line 45 of file IOFactory.php.

Constructor & Destructor Documentation

PHPExcel_IOFactory::__construct ( )
private

Private constructor for PHPExcel_IOFactory.

Definition at line 79 of file IOFactory.php.

{ }

Member Function Documentation

static PHPExcel_IOFactory::addSearchLocation (   $type = '',
  $location = '',
  $classname = '' 
)
static

Add search location.

public

Parameters
string$typeExample: IWriter
string$locationExample: PHPExcel/Writer/{0}.php
string$classnameExample: PHPExcel_Writer_{0}

Definition at line 117 of file IOFactory.php.

References $location, and $type.

{
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
} // function addSearchLocation()
static PHPExcel_IOFactory::createReader (   $readerType = '')
static

Create PHPExcel_Reader_IReader.

public

Parameters
string$readerTypeExample: Excel2007
Returns
PHPExcel_Reader_IReader
Exceptions
Exception

Definition at line 161 of file IOFactory.php.

Referenced by createReaderForFile().

{
// Search type
$searchType = 'IReader';
// Include class
foreach (self::$_searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $readerType, $searchLocation['class']);
$classFile = str_replace('{0}', $readerType, $searchLocation['path']);
$instance = new $className();
if (!is_null($instance)) {
return $instance;
}
}
}
// Nothing found...
throw new Exception("No $searchType found for type $readerType");
} // function createReader()

+ Here is the caller graph for this function:

static PHPExcel_IOFactory::createReaderForFile (   $pFilename)
static

Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution.

public

Parameters
string$pFileName
Returns
PHPExcel_Reader_IReader
Exceptions
Exception

Definition at line 222 of file IOFactory.php.

References $reader, and createReader().

Referenced by identify(), and load().

{
// First, lucky guess by inspecting file extension
$pathinfo = pathinfo($pFilename);
if (isset($pathinfo['extension'])) {
switch (strtolower($pathinfo['extension'])) {
case 'xlsx':
$reader = self::createReader('Excel2007');
break;
case 'xls':
break;
case 'ods':
break;
case 'slk':
break;
case 'xml':
$reader = self::createReader('Excel2003XML');
break;
case 'gnumeric':
$reader = self::createReader('Gnumeric');
break;
case 'csv':
// Do nothing
// We must not try to use CSV reader since it loads
// all files including Excel files etc.
break;
default:
break;
}
// Let's see if we are lucky
if (isset($reader) && $reader->canRead($pFilename)) {
return $reader;
}
}
// If we reach here then "lucky guess" didn't give any result
// Try loading using self::$_autoResolveClasses
foreach (self::$_autoResolveClasses as $autoResolveClass) {
$reader = self::createReader($autoResolveClass);
if ($reader->canRead($pFilename)) {
return $reader;
}
}
} // function createReaderForFile()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_IOFactory::createWriter ( PHPExcel  $phpExcel,
  $writerType = '' 
)
static

Create PHPExcel_Writer_IWriter.

public

Parameters
PHPExcel$phpExcel
string$writerTypeExample: Excel2007
Returns
PHPExcel_Writer_IWriter
Exceptions
Exception

Definition at line 131 of file IOFactory.php.

{
// Search type
$searchType = 'IWriter';
// Include class
foreach (self::$_searchLocations as $searchLocation) {
if ($searchLocation['type'] == $searchType) {
$className = str_replace('{0}', $writerType, $searchLocation['class']);
$classFile = str_replace('{0}', $writerType, $searchLocation['path']);
$instance = new $className($phpExcel);
if (!is_null($instance)) {
return $instance;
}
}
}
// Nothing found...
throw new Exception("No $searchType found for type $writerType");
} // function createWriter()
static PHPExcel_IOFactory::getSearchLocations ( )
static

Get search locations.

            @static
    @access public
Returns
array

Definition at line 88 of file IOFactory.php.

References $_searchLocations.

{
} // function getSearchLocations()
static PHPExcel_IOFactory::identify (   $pFilename)
static

Identify file type using automatic PHPExcel_Reader_IReader resolution.

public

Parameters
string$pFileName
Returns
string
Exceptions
Exception

Definition at line 205 of file IOFactory.php.

References $reader, and createReaderForFile().

{
$className = get_class($reader);
$classType = explode('_',$className);
unset($reader);
return array_pop($classType);
} // function identify()

+ Here is the call graph for this function:

static PHPExcel_IOFactory::load (   $pFilename)
static

Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution.

public

Parameters
string$pFileName
Returns
PHPExcel
Exceptions
Exception

Definition at line 191 of file IOFactory.php.

References $reader, and createReaderForFile().

{
return $reader->load($pFilename);
} // function load()

+ Here is the call graph for this function:

static PHPExcel_IOFactory::setSearchLocations (   $value)
static

Set search locations.

public

Parameters
array$value
Exceptions
Exception

Definition at line 100 of file IOFactory.php.

{
if (is_array($value)) {
self::$_searchLocations = $value;
} else {
throw new Exception('Invalid parameter passed.');
}
} // function setSearchLocations()

Field Documentation

PHPExcel_IOFactory::$_autoResolveClasses
staticprivate
Initial value:
array(
'Excel2007',
'Excel5',
'Excel2003XML',
'OOCalc',
'SYLK',
'Gnumeric',
'CSV',
)

Definition at line 66 of file IOFactory.php.

PHPExcel_IOFactory::$_searchLocations
staticprivate
Initial value:
array(
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{0}' )
)

Definition at line 54 of file IOFactory.php.

Referenced by getSearchLocations().


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