Change reader exceptions to PHPExcel_Reader_Exception

This commit is contained in:
Mark Baker 2012-10-29 23:48:29 +00:00
parent d66f61bfbb
commit 8f3640e44c
18 changed files with 167 additions and 123 deletions

View File

@ -92,7 +92,7 @@ class PHPExcel_Calculation_DateTime {
(PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
return PHPExcel_Calculation_Functions::VALUE();
}
if ((is_object($dateValue)) && ($dateValue instanceof PHPExcel_Shared_Date::$dateTimeObjectType)) {
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
$dateValue = PHPExcel_Shared_Date::PHPToExcel($dateValue);
} else {
$saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType();

View File

@ -124,13 +124,13 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* @access public
* @param string $pFileName
* @return boolean
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
return true;
@ -190,19 +190,19 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
*
* @access public
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Open file
$fileHandle = fopen($pFilename, 'r');
if ($fileHandle === false) {
throw new Exception("Could not open file " . $pFilename . " for reading.");
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
}
// Skip BOM, if any
@ -262,7 +262,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* @access public
* @param string $pFilename
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
@ -281,13 +281,13 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Create new PHPExcel
@ -302,7 +302,7 @@ class PHPExcel_Reader_CSV implements PHPExcel_Reader_IReader
// Open file
$fileHandle = fopen($pFilename, 'r');
if ($fileHandle === false) {
throw new Exception("Could not open file $pFilename for reading.");
throw new PHPExcel_Reader_Exception("Could not open file $pFilename for reading.");
}
// Skip BOM, if any

View File

@ -174,7 +174,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
*
* @param string $pFileName
* @return boolean
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
@ -196,7 +196,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Read sample data (first 2 KB will do)
@ -227,16 +227,16 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetNames($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
if (!$this->canRead($pFilename)) {
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$worksheetNames = array();
@ -258,13 +258,13 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetInfo = array();
@ -330,7 +330,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
@ -392,7 +392,7 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
@ -427,11 +427,11 @@ class PHPExcel_Reader_Excel2003XML implements PHPExcel_Reader_IReader
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
if (!$this->canRead($pFilename)) {
throw new Exception($pFilename . " is an Invalid Spreadsheet file.");
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
}
$xml = simplexml_load_file($pFilename);

View File

@ -226,18 +226,18 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
*
* @param string $pFileName
* @return boolean
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Check if zip class exists
if (!class_exists('ZipArchive',FALSE)) {
throw new Exception("ZipArchive library is not enabled");
throw new PHPExcel_Reader_Exception("ZipArchive library is not enabled");
}
$xl = false;
@ -269,13 +269,13 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetInfo = array();
@ -439,13 +439,13 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetNames($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetNames = array();
@ -478,13 +478,13 @@ class PHPExcel_Reader_Excel2007 implements PHPExcel_Reader_IReader
* Loads PHPExcel from file
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Initialisations

View File

@ -510,13 +510,13 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
*
* @param string $pFileName
* @return boolean
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
try {
@ -526,8 +526,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// get excel data
$res = $ole->read($pFilename);
return true;
} catch (Exception $e) {
} catch (PHPExcel_Reader_Exception $e) {
return false;
}
}
@ -537,13 +536,13 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetNames($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetNames = array();
@ -586,13 +585,13 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetInfo = array();
@ -681,7 +680,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
@ -1648,7 +1647,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
case self::XLS_WorkbookGlobals:
$version = self::_GetInt2d($recordData, 0);
if (($version != self::XLS_BIFF8) && ($version != self::XLS_BIFF7)) {
throw new Exception('Cannot read this Excel file. Version is too old.');
throw new PHPExcel_Reader_Exception('Cannot read this Excel file. Version is too old.');
}
$this->_version = $version;
break;
@ -1689,7 +1688,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// move stream pointer to next record
$this->_pos += 4 + $length;
throw new Exception('Cannot read encrypted file');
throw new PHPExcel_Reader_Exception('Cannot read encrypted file');
}
@ -2635,7 +2634,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
try {
$formula = $this->_getFormulaFromStructure($formulaStructure);
} catch (Exception $e) {
} catch (PHPExcel_Reader_Exception $e) {
$formula = '';
}
@ -3777,12 +3776,12 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// add cell value. If we can read formula, populate with formula, otherwise just used cached value
try {
if ($this->_version != self::XLS_BIFF8) {
throw new Exception('Not BIFF8. Can only read BIFF8 formulas');
throw new PHPExcel_Reader_Exception('Not BIFF8. Can only read BIFF8 formulas');
}
$formula = $this->_getFormulaFromStructure($formulaStructure); // get formula in human language
$cell->setValueExplicit('=' . $formula, PHPExcel_Cell_DataType::TYPE_FORMULA);
} catch (Exception $e) {
} catch (PHPExcel_Reader_Exception $e) {
$cell->setValueExplicit($value, $dataType);
}
} else {
@ -4299,7 +4298,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// offset: 0; size: 8; cell range address of all cells containing this hyperlink
try {
$cellRange = $this->_readBIFF8CellRangeAddressFixed($recordData, 0, 8);
} catch (Exception $e) {
} catch (PHPExcel_Reader_Exception $e) {
return;
}
@ -4583,7 +4582,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
if ($type == PHPExcel_Cell_DataValidation::TYPE_LIST) {
$formula1 = str_replace(chr(0), ',', $formula1);
}
} catch (Exception $e) {
} catch (PHPExcel_Reader_Exception $e) {
return;
}
$offset += $sz1;
@ -4600,7 +4599,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$formula2 = pack('v', $sz2) . $formula2; // prepend the length
try {
$formula2 = $this->_getFormulaFromStructure($formula2);
} catch (Exception $e) {
} catch (PHPExcel_Reader_Exception $e) {
return;
}
$offset += $sz2;
@ -4812,7 +4811,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
for ($i = 0; $i < $cref; ++$i) {
try {
$cellRange = $this->_readBIFF8CellRangeAddressFixed(substr($recordData, 27 + 8 * $i, 8));
} catch (Exception $e) {
} catch (PHPExcel_Reader_Exception $e) {
return;
}
$cellRanges[] = $cellRange;
@ -5244,7 +5243,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
* @param string Formula data
* @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas
* @return array
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
private function _getNextToken($formulaData, $baseCell = 'A1')
{
@ -5345,7 +5344,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$spacetype = 'type5';
break;
default:
throw new Exception('Unrecognized space type in tAttrSpace token');
throw new PHPExcel_Reader_Exception('Unrecognized space type in tAttrSpace token');
break;
}
// offset: 3; size: 1; number of inserted spaces/carriage returns
@ -5354,7 +5353,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$data = array('spacetype' => $spacetype, 'spacecount' => $spacecount);
break;
default:
throw new Exception('Unrecognized attribute flag in tAttr token');
throw new PHPExcel_Reader_Exception('Unrecognized attribute flag in tAttr token');
break;
}
break;
@ -5559,7 +5558,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
case 360: $function = 'PHONETIC'; $args = 1; break;
case 368: $function = 'BAHTTEXT'; $args = 1; break;
default:
throw new Exception('Unrecognized function in formula');
throw new PHPExcel_Reader_Exception('Unrecognized function in formula');
break;
}
$data = array('function' => $function, 'args' => $args);
@ -5663,7 +5662,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
case 366: $function = 'STDEVA'; break;
case 367: $function = 'VARA'; break;
default:
throw new Exception('Unrecognized function in formula');
throw new PHPExcel_Reader_Exception('Unrecognized function in formula');
break;
}
$data = array('function' => $function, 'args' => $args);
@ -5764,7 +5763,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$cellAddress = $this->_readBIFF8CellAddress(substr($formulaData, 3, 4));
$data = "$sheetRange!$cellAddress";
} catch (Exception $e) {
} catch (PHPExcel_Reader_Exception $e) {
// deleted sheet reference
$data = '#REF!';
}
@ -5783,7 +5782,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
$cellRangeAddress = $this->_readBIFF8CellRangeAddress(substr($formulaData, 3, 8));
$data = "$sheetRange!$cellRangeAddress";
} catch (Exception $e) {
} catch (PHPExcel_Reader_Exception $e) {
// deleted sheet reference
$data = '#REF!';
}
@ -5791,7 +5790,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
break;
// Unknown cases // don't know how to deal with
default:
throw new Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula');
throw new PHPExcel_Reader_Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula');
break;
}
@ -5885,7 +5884,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
*
* @param string $subData
* @return string
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
private function _readBIFF5CellRangeAddressFixed($subData)
{
@ -5903,7 +5902,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// check values
if ($fr > $lr || $fc > $lc) {
throw new Exception('Not a cell range address');
throw new PHPExcel_Reader_Exception('Not a cell range address');
}
// column index to letter
@ -5924,7 +5923,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
*
* @param string $subData
* @return string
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
private function _readBIFF8CellRangeAddressFixed($subData)
{
@ -5942,7 +5941,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
// check values
if ($fr > $lr || $fc > $lc) {
throw new Exception('Not a cell range address');
throw new PHPExcel_Reader_Exception('Not a cell range address');
}
// column index to letter
@ -6152,11 +6151,11 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
* Get a sheet range like Sheet1:Sheet3 from REF index
* Note: If there is only one sheet in the range, one gets e.g Sheet1
* It can also happen that the REF structure uses the -1 (FFFF) code to indicate deleted sheets,
* in which case an exception is thrown
* in which case an PHPExcel_Reader_Exception is thrown
*
* @param int $index
* @return string|false
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
private function _readSheetRangeByRefIndex($index)
{
@ -6168,7 +6167,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
case 'internal':
// check if we have a deleted 3d reference
if ($this->_ref[$index]['firstSheetIndex'] == 0xFFFF or $this->_ref[$index]['lastSheetIndex'] == 0xFFFF) {
throw new Exception('Deleted sheet reference');
throw new PHPExcel_Reader_Exception('Deleted sheet reference');
}
// we have normal sheet range (collapsed or uncollapsed)
@ -6198,7 +6197,7 @@ class PHPExcel_Reader_Excel5 implements PHPExcel_Reader_IReader
default:
// TODO: external sheet support
throw new Exception('Excel5 reader only supports internal sheets in fomulas');
throw new PHPExcel_Reader_Exception('Excel5 reader only supports internal sheets in fomulas');
break;
}
}

View File

@ -0,0 +1,52 @@
<?php
/**
* PHPExcel
*
* Copyright (c) 2006 - 2012 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Reader_Exception
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2012 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_Exception extends Exception {
/**
* Error handler callback
*
* @param mixed $code
* @param mixed $string
* @param mixed $file
* @param mixed $line
* @param mixed $context
*/
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
$e = new self($string, $code);
$e->line = $line;
$e->file = $file;
throw $e;
}
}

View File

@ -191,18 +191,18 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
*
* @param string $pFileName
* @return boolean
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Check if gzlib functions are available
if (!function_exists('gzread')) {
throw new Exception("gzlib library is not enabled");
throw new PHPExcel_Reader_Exception("gzlib library is not enabled");
}
// Read signature data (first 3 bytes)
@ -222,13 +222,13 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$gFileData = $this->_gzfileGetContents($pFilename);
@ -286,7 +286,7 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
@ -302,13 +302,13 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetNames($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$gFileData = $this->_gzfileGetContents($pFilename);
@ -334,13 +334,13 @@ class PHPExcel_Reader_Gnumeric implements PHPExcel_Reader_IReader
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$timezoneObj = new DateTimeZone('Europe/London');

View File

@ -120,13 +120,13 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader
*
* @param string $pFileName
* @return boolean
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Read sample data (first 2 KB will do)
@ -147,7 +147,7 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
@ -243,7 +243,7 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader
private function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent){
foreach($element->childNodes as $child){
if ($child instanceOf DOMText) {
if ($child instanceof DOMText) {
$domText = preg_replace('/\s+/',' ',trim($child->nodeValue));
if (is_string($cellContent)) {
// simply append the text if the cell content is a plain text string
@ -252,7 +252,7 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader
// but if we have a rich text run instead, we need to append it correctly
// TODO
}
} elseif($child instanceOf DOMElement) {
} elseif($child instanceof DOMElement) {
echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
$attributeArray = array();
@ -438,17 +438,17 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
if (!is_file($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! The given file is not a regular file.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! The given file is not a regular file.");
}
// Create new PHPExcel
@ -462,7 +462,7 @@ class PHPExcel_Reader_HTML implements PHPExcel_Reader_IReader
// Load the HTML file into the DOM object
$loaded = $dom->loadHTMLFile($pFilename);
if ($loaded === false) {
throw new Exception('Failed to load ',$pFilename,' as a DOM Document');
throw new PHPExcel_Reader_Exception('Failed to load ',$pFilename,' as a DOM Document');
}
// Discard white space

View File

@ -47,7 +47,7 @@ interface PHPExcel_Reader_IReader
* Loads PHPExcel from file
*
* @param string $pFileName
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename);
}

View File

@ -180,18 +180,18 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
*
* @param string $pFileName
* @return boolean
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Check if zip class exists
if (!class_exists('ZipArchive',FALSE)) {
throw new Exception("ZipArchive library is not enabled");
throw new PHPExcel_Reader_Exception("ZipArchive library is not enabled");
}
// Load file
@ -219,13 +219,13 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
* Reads names of the worksheets from a file, without parsing the whole file to a PHPExcel object
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetNames($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetNames = array();
@ -256,7 +256,7 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
@ -284,13 +284,13 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$worksheetInfo = array();
@ -358,13 +358,13 @@ class PHPExcel_Reader_OOCalc implements PHPExcel_Reader_IReader
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
$timezoneObj = new DateTimeZone('Europe/London');

View File

@ -93,13 +93,13 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
*
* @param string $pFileName
* @return boolean
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function canRead($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Read sample data (first 2 KB will do)
@ -171,19 +171,19 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
*
* @param string $pFilename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function listWorksheetInfo($pFilename)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Open file
$fileHandle = fopen($pFilename, 'r');
if ($fileHandle === false) {
throw new Exception("Could not open file " . $pFilename . " for reading.");
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
}
$worksheetInfo = array();
@ -244,7 +244,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
*
* @param string $pFilename
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function load($pFilename)
{
@ -262,13 +262,13 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
* @param string $pFilename
* @param PHPExcel $objPHPExcel
* @return PHPExcel
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Check if file exists
if (!file_exists($pFilename)) {
throw new Exception("Could not open " . $pFilename . " for reading! File does not exist.");
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
}
// Create new PHPExcel
@ -283,7 +283,7 @@ class PHPExcel_Reader_SYLK implements PHPExcel_Reader_IReader
// Open file
$fileHandle = fopen($pFilename, 'r');
if ($fileHandle === false) {
throw new Exception("Could not open file $pFilename for reading.");
throw new PHPExcel_Reader_Exception("Could not open file $pFilename for reading.");
}
// Loop through file

View File

@ -69,15 +69,6 @@ class PHPExcel_Shared_Date
*/
private static $ExcelBaseDate = self::CALENDAR_WINDOWS_1900;
/*
* Object type for PHP Date/Time values
*
* @private
* @var string
*/
public static $dateTimeObjectType = 'DateTime';
/**
* Set the Excel calendar (Windows 1900 or Mac 1904)
*
@ -172,7 +163,7 @@ class PHPExcel_Shared_Date
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$retValue = FALSE;
if ((is_object($dateValue)) && ($dateValue instanceof self::$dateTimeObjectType)) {
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'),
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
);

View File

@ -70,13 +70,13 @@ class PHPExcel_Shared_OLERead {
* Read the file
*
* @param $sFileName string Filename
* @throws Exception
* @throws PHPExcel_Reader_Exception
*/
public function read($sFileName)
{
// Check if file exists and is readable
if(!is_readable($sFileName)) {
throw new Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable.");
throw new PHPExcel_Reader_Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable.");
}
// Get the file data
@ -84,7 +84,7 @@ class PHPExcel_Shared_OLERead {
// Check OLE identifier
if (substr($this->data, 0, 8) != self::IDENTIFIER_OLE) {
throw new Exception('The filename ' . $sFileName . ' is not recognised as an OLE file');
throw new PHPExcel_Reader_Exception('The filename ' . $sFileName . ' is not recognised as an OLE file');
}
// Total number of sectors used for the SAT

View File

@ -2782,7 +2782,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
} elseif ($key == '_drawingCollection') {
$newCollection = clone $this->_drawingCollection;
$this->_drawingCollection = $newCollection;
} elseif (($key == '_autoFilter') && (is_a($this->_autoFilter,'PHPExcel_Worksheet_AutoFilter'))) {
} elseif (($key == '_autoFilter') && ($this->_autoFilter instanceof PHPExcel_Worksheet_AutoFilter)) {
$newAutoFilter = clone $this->_autoFilter;
$this->_autoFilter = $newAutoFilter;
$this->_autoFilter->setParent($this);

View File

@ -30,7 +30,7 @@ $inputFileName = './sampleData/example_1.xls';
echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format<br />';
try {
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
} catch(Exception $e) {
} catch(PHPExcel_Reader_Exception $e) {
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}

View File

@ -27,6 +27,8 @@ Fixed in develop branch:
- Bugfix: (Asker) Work item 18777 - Error in PHPEXCEL/Calculation.php script on line 2976 (stack pop check)
- Bugfix: (MBaker) Work item 18794 - CSV files without a file extension being identified as HTML
- Bugfix: (MBaker) Work item GH-66 - Wrong check for maximum number of rows in Excel5 Writer
- General: (kea) Improved AdvancedValueBinder for currency
- Bugfix: (techhead) Work item GH-70 - Fixed formula/formatting bug when removing rows
--------------------------------------------------------------------------------