30 if (!defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../');
38 require_once PHPEXCEL_ROOT .
'PHPExcel.php';
41 require_once PHPEXCEL_ROOT .
'PHPExcel/Writer/IWriter.php';
44 require_once PHPEXCEL_ROOT .
'PHPExcel/Reader/IReader.php';
62 array(
'type' =>
'IWriter',
'path' =>
'PHPExcel/Writer/{0}.php',
'class' =>
'PHPExcel_Writer_{0}' ),
63 array(
'type' =>
'IReader',
'path' =>
'PHPExcel/Reader/{0}.php',
'class' =>
'PHPExcel_Reader_{0}' )
99 if (is_array($value)) {
100 self::$_searchLocations = $value;
102 throw new Exception(
'Invalid parameter passed.');
114 self::$_searchLocations[] = array(
'type' =>
$type,
'path' =>
$location,
'class' => $classname );
126 $searchType =
'IWriter';
129 foreach (self::$_searchLocations as $searchLocation) {
130 if ($searchLocation[
'type'] == $searchType) {
131 $className = str_replace(
'{0}', $writerType, $searchLocation[
'class']);
132 $classFile = str_replace(
'{0}', $writerType, $searchLocation[
'path']);
134 if (!class_exists($className)) {
135 require_once PHPEXCEL_ROOT . $classFile;
138 $instance =
new $className($phpExcel);
139 if (!is_null($instance)) {
146 throw new Exception(
"No $searchType found for type $writerType");
157 $searchType =
'IReader';
160 foreach (self::$_searchLocations as $searchLocation) {
161 if ($searchLocation[
'type'] == $searchType) {
162 $className = str_replace(
'{0}', $readerType, $searchLocation[
'class']);
163 $classFile = str_replace(
'{0}', $readerType, $searchLocation[
'path']);
165 if (!class_exists($className)) {
166 require_once PHPEXCEL_ROOT . $classFile;
169 $instance =
new $className();
170 if (!is_null($instance)) {
177 throw new Exception(
"No $searchType found for type $readerType");
186 public static function load($pFilename) {
188 return $reader->load($pFilename);
200 foreach (self::$_autoResolveClasses as $autoResolveClass) {
202 if (
$reader->canRead($pFilename)) {
207 throw new Exception(
"Could not automatically determine PHPExcel_Reader_IReader for file.");