diff --git a/Classes/PHPExcel/Calculation/DateTime.php b/Classes/PHPExcel/Calculation/DateTime.php index ebc9359..a24df5c 100644 --- a/Classes/PHPExcel/Calculation/DateTime.php +++ b/Classes/PHPExcel/Calculation/DateTime.php @@ -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(); diff --git a/Classes/PHPExcel/Cell/AdvancedValueBinder.php b/Classes/PHPExcel/Cell/AdvancedValueBinder.php index 50a07f9..add0a57 100644 --- a/Classes/PHPExcel/Cell/AdvancedValueBinder.php +++ b/Classes/PHPExcel/Cell/AdvancedValueBinder.php @@ -113,8 +113,8 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder // Check for currency $currencyCode = PHPExcel_Shared_String::getCurrencyCode(); - $decimalSeparator = PHPExcel_Shared_String::getDecimalSeparator(); - $thousandsSeparator = PHPExcel_Shared_String::getThousandsSeparator(); + $decimalSeparator = PHPExcel_Shared_String::getDecimalSeparator(); + $thousandsSeparator = PHPExcel_Shared_String::getThousandsSeparator(); if (preg_match('/^'.preg_quote($currencyCode).' *(\d{1,3}('.preg_quote($thousandsSeparator).'\d{3})*|(\d+))('.preg_quote($decimalSeparator).'\d{2})?$/', $value)) { // Convert value to number $value = (float) trim(str_replace(array($currencyCode, $thousandsSeparator, $decimalSeparator), array('', '', '.'), $value)); diff --git a/Classes/PHPExcel/Reader/CSV.php b/Classes/PHPExcel/Reader/CSV.php index 8553a8b..e868529 100644 --- a/Classes/PHPExcel/Reader/CSV.php +++ b/Classes/PHPExcel/Reader/CSV.php @@ -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 diff --git a/Classes/PHPExcel/Reader/Excel2003XML.php b/Classes/PHPExcel/Reader/Excel2003XML.php index 4f6cfea..60d51a4 100644 --- a/Classes/PHPExcel/Reader/Excel2003XML.php +++ b/Classes/PHPExcel/Reader/Excel2003XML.php @@ -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); diff --git a/Classes/PHPExcel/Reader/Excel2007.php b/Classes/PHPExcel/Reader/Excel2007.php index 8d45cc7..d296e92 100644 --- a/Classes/PHPExcel/Reader/Excel2007.php +++ b/Classes/PHPExcel/Reader/Excel2007.php @@ -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 diff --git a/Classes/PHPExcel/Reader/Excel5.php b/Classes/PHPExcel/Reader/Excel5.php index 165eca2..2c51014 100644 --- a/Classes/PHPExcel/Reader/Excel5.php +++ b/Classes/PHPExcel/Reader/Excel5.php @@ -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; } } diff --git a/Classes/PHPExcel/Reader/Exception.php b/Classes/PHPExcel/Reader/Exception.php new file mode 100644 index 0000000..8180dce --- /dev/null +++ b/Classes/PHPExcel/Reader/Exception.php @@ -0,0 +1,52 @@ +line = $line; + $e->file = $file; + throw $e; + } +} diff --git a/Classes/PHPExcel/Reader/Gnumeric.php b/Classes/PHPExcel/Reader/Gnumeric.php index 355e71c..3f1e453 100644 --- a/Classes/PHPExcel/Reader/Gnumeric.php +++ b/Classes/PHPExcel/Reader/Gnumeric.php @@ -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'); diff --git a/Classes/PHPExcel/Reader/HTML.php b/Classes/PHPExcel/Reader/HTML.php index 0bb7ec1..1d1c4e3 100644 --- a/Classes/PHPExcel/Reader/HTML.php +++ b/Classes/PHPExcel/Reader/HTML.php @@ -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 'DOM ELEMENT: ' , strtoupper($child->nodeName) , '
'; $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 diff --git a/Classes/PHPExcel/Reader/IReader.php b/Classes/PHPExcel/Reader/IReader.php index e36495e..c26f1d4 100644 --- a/Classes/PHPExcel/Reader/IReader.php +++ b/Classes/PHPExcel/Reader/IReader.php @@ -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); } diff --git a/Classes/PHPExcel/Reader/OOCalc.php b/Classes/PHPExcel/Reader/OOCalc.php index ab3023e..f504e40 100644 --- a/Classes/PHPExcel/Reader/OOCalc.php +++ b/Classes/PHPExcel/Reader/OOCalc.php @@ -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'); diff --git a/Classes/PHPExcel/Reader/SYLK.php b/Classes/PHPExcel/Reader/SYLK.php index 6aae752..4b5d892 100644 --- a/Classes/PHPExcel/Reader/SYLK.php +++ b/Classes/PHPExcel/Reader/SYLK.php @@ -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 diff --git a/Classes/PHPExcel/Shared/Date.php b/Classes/PHPExcel/Shared/Date.php index 1507d58..6043bd3 100644 --- a/Classes/PHPExcel/Shared/Date.php +++ b/Classes/PHPExcel/Shared/Date.php @@ -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') ); diff --git a/Classes/PHPExcel/Shared/OLERead.php b/Classes/PHPExcel/Shared/OLERead.php index 5e72ccf..be672b1 100644 --- a/Classes/PHPExcel/Shared/OLERead.php +++ b/Classes/PHPExcel/Shared/OLERead.php @@ -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 diff --git a/Classes/PHPExcel/Worksheet.php b/Classes/PHPExcel/Worksheet.php index 00f68fd..8964dff 100644 --- a/Classes/PHPExcel/Worksheet.php +++ b/Classes/PHPExcel/Worksheet.php @@ -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); diff --git a/Documentation/Examples/Reader/exampleReader16.php b/Documentation/Examples/Reader/exampleReader16.php index 0542006..62d82ea 100644 --- a/Documentation/Examples/Reader/exampleReader16.php +++ b/Documentation/Examples/Reader/exampleReader16.php @@ -30,7 +30,7 @@ $inputFileName = './sampleData/example_1.xls'; echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory to identify the format
'; try { $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); -} catch(Exception $e) { +} catch(PHPExcel_Reader_Exception $e) { die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage()); } diff --git a/Documentation/PHPExcel User Documentation - Reading Spreadsheet Files.doc b/Documentation/PHPExcel User Documentation - Reading Spreadsheet Files.doc index 206f2f2..221f44b 100644 Binary files a/Documentation/PHPExcel User Documentation - Reading Spreadsheet Files.doc and b/Documentation/PHPExcel User Documentation - Reading Spreadsheet Files.doc differ diff --git a/changelog.txt b/changelog.txt index f00fd78..2ba004a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -24,9 +24,11 @@ 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 +- 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 --------------------------------------------------------------------------------