More PSR-2 changes, and fixes for a couple of breakages introduced by the last commit

This commit is contained in:
MarkBaker 2015-05-08 01:09:27 +01:00
parent 4f8c9bfc96
commit b8f67c6f4d
31 changed files with 14776 additions and 14680 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
PHPExcel_Autoloader::Register(); PHPExcel_Autoloader::register();
// As we always try to run the autoloader before anything else, we can use it to do a few // As we always try to run the autoloader before anything else, we can use it to do a few
// simple checks and initialisations // simple checks and initialisations
//PHPExcel_Shared_ZipStreamWrapper::register(); //PHPExcel_Shared_ZipStreamWrapper::register();
@ -41,7 +41,7 @@ class PHPExcel_Autoloader
* Register the Autoloader with SPL * Register the Autoloader with SPL
* *
*/ */
public static function Register() public static function register()
{ {
if (function_exists('__autoload')) { if (function_exists('__autoload')) {
// Register any existing autoloader function with SPL, so we don't get any clashes // Register any existing autoloader function with SPL, so we don't get any clashes
@ -49,9 +49,9 @@ class PHPExcel_Autoloader
} }
// Register ourselves with SPL // Register ourselves with SPL
if (version_compare(PHP_VERSION, '5.3.0') >= 0) { if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load'), true, true); return spl_autoload_register(array('PHPExcel_Autoloader', 'load'), true, true);
} else { } else {
return spl_autoload_register(array('PHPExcel_Autoloader', 'Load')); return spl_autoload_register(array('PHPExcel_Autoloader', 'load'));
} }
} }
@ -60,7 +60,7 @@ class PHPExcel_Autoloader
* *
* @param string $pClassName Name of the object to load * @param string $pClassName Name of the object to load
*/ */
public static function Load($pClassName) public static function load($pClassName)
{ {
if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) { if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
// Either already loaded, or not a PHPExcel class request // Either already loaded, or not a PHPExcel class request

View File

@ -1,6 +1,16 @@
<?php <?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel * PHPExcel_Calculation_Database
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,30 +34,10 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
class PHPExcel_Calculation_Database
{
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/** /**
* @ignore * fieldExtract
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Calculation_Database
*
* @category PHPExcel
* @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Calculation_Database {
/**
* __fieldExtract
* *
* Extracts the column ID to use for the data field. * Extracts the column ID to use for the data field.
* *
@ -64,20 +54,21 @@ class PHPExcel_Calculation_Database {
* @return string|NULL * @return string|NULL
* *
*/ */
private static function __fieldExtract($database,$field) { private static function fieldExtract($database, $field)
{
$field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field)); $field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field));
$fieldNames = array_map('strtoupper',array_shift($database)); $fieldNames = array_map('strtoupper', array_shift($database));
if (is_numeric($field)) { if (is_numeric($field)) {
$keys = array_keys($fieldNames); $keys = array_keys($fieldNames);
return $keys[$field-1]; return $keys[$field-1];
} }
$key = array_search($field,$fieldNames); $key = array_search($field, $fieldNames);
return ($key) ? $key : NULL; return ($key) ? $key : null;
} }
/** /**
* __filter * filter
* *
* Parses the selection criteria, extracts the database rows that match those criteria, and * Parses the selection criteria, extracts the database rows that match those criteria, and
* returns that subset of rows. * returns that subset of rows.
@ -95,47 +86,48 @@ class PHPExcel_Calculation_Database {
* @return array of mixed * @return array of mixed
* *
*/ */
private static function __filter($database,$criteria) { private static function filter($database, $criteria)
{
$fieldNames = array_shift($database); $fieldNames = array_shift($database);
$criteriaNames = array_shift($criteria); $criteriaNames = array_shift($criteria);
// Convert the criteria into a set of AND/OR conditions with [:placeholders] // Convert the criteria into a set of AND/OR conditions with [:placeholders]
$testConditions = $testValues = array(); $testConditions = $testValues = array();
$testConditionsCount = 0; $testConditionsCount = 0;
foreach($criteriaNames as $key => $criteriaName) { foreach ($criteriaNames as $key => $criteriaName) {
$testCondition = array(); $testCondition = array();
$testConditionCount = 0; $testConditionCount = 0;
foreach($criteria as $row => $criterion) { foreach ($criteria as $row => $criterion) {
if ($criterion[$key] > '') { if ($criterion[$key] > '') {
$testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::_ifCondition($criterion[$key]); $testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::_ifCondition($criterion[$key]);
$testConditionCount++; $testConditionCount++;
} }
} }
if ($testConditionCount > 1) { if ($testConditionCount > 1) {
$testConditions[] = 'OR('.implode(',',$testCondition).')'; $testConditions[] = 'OR(' . implode(',', $testCondition) . ')';
$testConditionsCount++; $testConditionsCount++;
} elseif($testConditionCount == 1) { } elseif ($testConditionCount == 1) {
$testConditions[] = $testCondition[0]; $testConditions[] = $testCondition[0];
$testConditionsCount++; $testConditionsCount++;
} }
} }
if ($testConditionsCount > 1) { if ($testConditionsCount > 1) {
$testConditionSet = 'AND('.implode(',',$testConditions).')'; $testConditionSet = 'AND(' . implode(',', $testConditions) . ')';
} elseif($testConditionsCount == 1) { } elseif ($testConditionsCount == 1) {
$testConditionSet = $testConditions[0]; $testConditionSet = $testConditions[0];
} }
// Loop through each row of the database // Loop through each row of the database
foreach($database as $dataRow => $dataValues) { foreach ($database as $dataRow => $dataValues) {
// Substitute actual values from the database row for our [:placeholders] // Substitute actual values from the database row for our [:placeholders]
$testConditionList = $testConditionSet; $testConditionList = $testConditionSet;
foreach($criteriaNames as $key => $criteriaName) { foreach ($criteriaNames as $key => $criteriaName) {
$k = array_search($criteriaName,$fieldNames); $k = array_search($criteriaName, $fieldNames);
if (isset($dataValues[$k])) { if (isset($dataValues[$k])) {
$dataValue = $dataValues[$k]; $dataValue = $dataValues[$k];
$dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::_wrapResult(strtoupper($dataValue)) : $dataValue; $dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::_wrapResult(strtoupper($dataValue)) : $dataValue;
$testConditionList = str_replace('[:'.$criteriaName.']',$dataValue,$testConditionList); $testConditionList = str_replace('[:' . $criteriaName . ']', $dataValue, $testConditionList);
} }
} }
// evaluate the criteria against the row data // evaluate the criteria against the row data
@ -150,6 +142,19 @@ class PHPExcel_Calculation_Database {
} }
private static function getFilteredColumn($database, $field, $criteria)
{
// reduce the database to a set of rows that match all the criteria
$database = self::filter($database, $criteria);
// extract an array of values for the requested column
$colData = array();
foreach ($database as $row) {
$colData[] = $row[$field];
}
return $colData;
}
/** /**
* DAVERAGE * DAVERAGE
* *
@ -177,22 +182,18 @@ class PHPExcel_Calculation_Database {
* @return float * @return float
* *
*/ */
public static function DAVERAGE($database,$field,$criteria) { public static function DAVERAGE($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_Statistical::AVERAGE($colData); return PHPExcel_Calculation_Statistical::AVERAGE(
} // function DAVERAGE() self::getFilteredColumn($database, $field, $criteria)
);
}
/** /**
@ -229,23 +230,18 @@ class PHPExcel_Calculation_Database {
* database that match the criteria. * database that match the criteria.
* *
*/ */
public static function DCOUNT($database,$field,$criteria) { public static function DCOUNT($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_Statistical::COUNT($colData); return PHPExcel_Calculation_Statistical::COUNT(
} // function DCOUNT() self::getFilteredColumn($database, $field, $criteria)
);
}
/** /**
@ -278,23 +274,26 @@ class PHPExcel_Calculation_Database {
* database that match the criteria. * database that match the criteria.
* *
*/ */
public static function DCOUNTA($database,$field,$criteria) { public static function DCOUNTA($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
} }
// reduce the database to a set of rows that match all the criteria // reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria); $database = self::filter($database, $criteria);
// extract an array of values for the requested column // extract an array of values for the requested column
$colData = array(); $colData = array();
foreach($database as $row) { foreach ($database as $row) {
$colData[] = $row[$field]; $colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_Statistical::COUNTA($colData); return PHPExcel_Calculation_Statistical::COUNTA(
} // function DCOUNTA() self::getFilteredColumn($database, $field, $criteria)
);
}
/** /**
@ -325,27 +324,21 @@ class PHPExcel_Calculation_Database {
* @return mixed * @return mixed
* *
*/ */
public static function DGET($database,$field,$criteria) { public static function DGET($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
$colData = self::getFilteredColumn($database, $field, $criteria);
if (count($colData) > 1) { if (count($colData) > 1) {
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
} }
return $colData[0]; return $colData[0];
} // function DGET() }
/** /**
@ -376,23 +369,18 @@ class PHPExcel_Calculation_Database {
* @return float * @return float
* *
*/ */
public static function DMAX($database,$field,$criteria) { public static function DMAX($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_Statistical::MAX($colData); return PHPExcel_Calculation_Statistical::MAX(
} // function DMAX() self::getFilteredColumn($database, $field, $criteria)
);
}
/** /**
@ -423,23 +411,18 @@ class PHPExcel_Calculation_Database {
* @return float * @return float
* *
*/ */
public static function DMIN($database,$field,$criteria) { public static function DMIN($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_Statistical::MIN($colData); return PHPExcel_Calculation_Statistical::MIN(
} // function DMIN() self::getFilteredColumn($database, $field, $criteria)
);
}
/** /**
@ -469,23 +452,18 @@ class PHPExcel_Calculation_Database {
* @return float * @return float
* *
*/ */
public static function DPRODUCT($database,$field,$criteria) { public static function DPRODUCT($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_MathTrig::PRODUCT($colData); return PHPExcel_Calculation_MathTrig::PRODUCT(
} // function DPRODUCT() self::getFilteredColumn($database, $field, $criteria)
);
}
/** /**
@ -516,23 +494,18 @@ class PHPExcel_Calculation_Database {
* @return float * @return float
* *
*/ */
public static function DSTDEV($database,$field,$criteria) { public static function DSTDEV($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_Statistical::STDEV($colData); return PHPExcel_Calculation_Statistical::STDEV(
} // function DSTDEV() self::getFilteredColumn($database, $field, $criteria)
);
}
/** /**
@ -563,23 +536,18 @@ class PHPExcel_Calculation_Database {
* @return float * @return float
* *
*/ */
public static function DSTDEVP($database,$field,$criteria) { public static function DSTDEVP($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_Statistical::STDEVP($colData); return PHPExcel_Calculation_Statistical::STDEVP(
} // function DSTDEVP() self::getFilteredColumn($database, $field, $criteria)
);
}
/** /**
@ -609,23 +577,18 @@ class PHPExcel_Calculation_Database {
* @return float * @return float
* *
*/ */
public static function DSUM($database,$field,$criteria) { public static function DSUM($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_MathTrig::SUM($colData); return PHPExcel_Calculation_MathTrig::SUM(
} // function DSUM() self::getFilteredColumn($database, $field, $criteria)
);
}
/** /**
@ -656,23 +619,18 @@ class PHPExcel_Calculation_Database {
* @return float * @return float
* *
*/ */
public static function DVAR($database,$field,$criteria) { public static function DVAR($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_Statistical::VARFunc($colData); return PHPExcel_Calculation_Statistical::VARFunc(
} // function DVAR() self::getFilteredColumn($database, $field, $criteria)
);
}
/** /**
@ -703,23 +661,16 @@ class PHPExcel_Calculation_Database {
* @return float * @return float
* *
*/ */
public static function DVARP($database,$field,$criteria) { public static function DVARP($database, $field, $criteria)
$field = self::__fieldExtract($database,$field); {
$field = self::fieldExtract($database, $field);
if (is_null($field)) { if (is_null($field)) {
return NULL; return null;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
} }
// Return // Return
return PHPExcel_Calculation_Statistical::VARP($colData); return PHPExcel_Calculation_Statistical::VARP(
} // function DVARP() self::getFilteredColumn($database, $field, $criteria)
);
}
} // class PHPExcel_Calculation_Database }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -141,7 +141,7 @@ class PHPExcel_Calculation_Financial {
$daysPerYear = 365; $daysPerYear = 365;
break; break;
case 1 : case 1 :
$daysPerYear = (PHPExcel_Calculation_DateTime::_isLeapYear($year)) ? 366 : 365; $daysPerYear = (PHPExcel_Calculation_DateTime::isLeapYear($year)) ? 366 : 365;
break; break;
default : default :
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
@ -397,7 +397,7 @@ class PHPExcel_Calculation_Financial {
$purchasedYear = PHPExcel_Calculation_DateTime::YEAR($purchased); $purchasedYear = PHPExcel_Calculation_DateTime::YEAR($purchased);
$yearFrac = PHPExcel_Calculation_DateTime::YEARFRAC($purchased, $firstPeriod, $basis); $yearFrac = PHPExcel_Calculation_DateTime::YEARFRAC($purchased, $firstPeriod, $basis);
if (($basis == 1) && ($yearFrac < 1) && (PHPExcel_Calculation_DateTime::_isLeapYear($purchasedYear))) { if (($basis == 1) && ($yearFrac < 1) && (PHPExcel_Calculation_DateTime::isLeapYear($purchasedYear))) {
$yearFrac *= 365 / 366; $yearFrac *= 365 / 366;
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPExcel_Calculation_Token_Stack * PHPExcel_Calculation_Token_Stack
* *

View File

@ -1,6 +1,16 @@
<?php <?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel * PHPExcel_Cell_AdvancedValueBinder
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,25 +34,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Cell_AdvancedValueBinder
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
{ {
/** /**
@ -66,16 +57,16 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) { if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
// Test for booleans using locale-setting // Test for booleans using locale-setting
if ($value == PHPExcel_Calculation::getTRUE()) { if ($value == PHPExcel_Calculation::getTRUE()) {
$cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL); $cell->setValueExplicit(true, PHPExcel_Cell_DataType::TYPE_BOOL);
return true; return true;
} elseif($value == PHPExcel_Calculation::getFALSE()) { } elseif($value == PHPExcel_Calculation::getFALSE()) {
$cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL); $cell->setValueExplicit(false, PHPExcel_Cell_DataType::TYPE_BOOL);
return true; return true;
} }
// Check for number in scientific format // Check for number in scientific format
if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) { if (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NUMBER.'$/', $value)) {
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
return true; return true;
} }
@ -84,7 +75,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Convert value to number // Convert value to number
$value = $matches[2] / $matches[3]; $value = $matches[2] / $matches[3];
if ($matches[1] == '-') $value = 0 - $value; if ($matches[1] == '-') $value = 0 - $value;
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( '??/??' ); ->getNumberFormat()->setFormatCode( '??/??' );
@ -93,7 +84,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Convert value to number // Convert value to number
$value = $matches[2] + ($matches[3] / $matches[4]); $value = $matches[2] + ($matches[3] / $matches[4]);
if ($matches[1] == '-') $value = 0 - $value; if ($matches[1] == '-') $value = 0 - $value;
$cell->setValueExplicit( (float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( '# ??/??' ); ->getNumberFormat()->setFormatCode( '# ??/??' );
@ -107,7 +98,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 ); ->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
return true; return true;
} }
@ -122,7 +113,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( ->getNumberFormat()->setFormatCode(
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ) str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE)
); );
return true; return true;
} elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) { } elseif (preg_match('/^\$ *(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $value)) {
@ -131,7 +122,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE ); ->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE);
return true; return true;
} }
@ -143,7 +134,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 ); ->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3);
return true; return true;
} }
@ -156,7 +147,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 ); ->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4);
return true; return true;
} }
@ -176,12 +167,12 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
} }
// Check for newline character "\n" // Check for newline character "\n"
if (strpos($value, "\n") !== FALSE) { if (strpos($value, "\n") !== false) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value); $value = PHPExcel_Shared_String::SanitizeUTF8($value);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING); $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle($cell->getCoordinate())
->getAlignment()->setWrapText(TRUE); ->getAlignment()->setWrapText(true);
return true; return true;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Cell_DataType
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Cell_DataType
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_DataType class PHPExcel_Cell_DataType
{ {
/* Data types */ /* Data types */
@ -50,7 +42,7 @@ class PHPExcel_Cell_DataType
* *
* @var array * @var array
*/ */
private static $_errorCodes = array( private static $errorCodes = array(
'#NULL!' => 0, '#NULL!' => 0,
'#DIV/0!' => 1, '#DIV/0!' => 1,
'#VALUE!' => 2, '#VALUE!' => 2,
@ -65,8 +57,9 @@ class PHPExcel_Cell_DataType
* *
* @return array * @return array
*/ */
public static function getErrorCodes() { public static function getErrorCodes()
return self::$_errorCodes; {
return self::$errorCodes;
} }
/** /**
@ -76,7 +69,8 @@ class PHPExcel_Cell_DataType
* @param mixed $pValue * @param mixed $pValue
* @return string * @return string
*/ */
public static function dataTypeForValue($pValue = null) { public static function dataTypeForValue($pValue = null)
{
return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue); return PHPExcel_Cell_DefaultValueBinder::dataTypeForValue($pValue);
} }
@ -112,7 +106,7 @@ class PHPExcel_Cell_DataType
{ {
$pValue = (string) $pValue; $pValue = (string) $pValue;
if ( !array_key_exists($pValue, self::$_errorCodes) ) { if (!array_key_exists($pValue, self::$errorCodes)) {
$pValue = '#NULL!'; $pValue = '#NULL!';
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Cell_DataValidation
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Cell_DataValidation
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_DataValidation class PHPExcel_Cell_DataValidation
{ {
/* Data validation types */ /* Data validation types */

View File

@ -1,6 +1,16 @@
<?php <?php
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/** /**
* PHPExcel * PHPExcel_Cell_DefaultValueBinder
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,25 +34,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Cell_DefaultValueBinder
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
{ {
/** /**
@ -67,7 +58,7 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
} }
// Set value explicit // Set value explicit
$cell->setValueExplicit( $value, self::dataTypeForValue($value) ); $cell->setValueExplicit($value, self::dataTypeForValue($value));
// Done! // Done!
return true; return true;
@ -79,7 +70,8 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
* @param mixed $pValue * @param mixed $pValue
* @return string * @return string
*/ */
public static function dataTypeForValue($pValue = null) { public static function dataTypeForValue($pValue = null)
{
// Match the value against a few data types // Match the value against a few data types
if ($pValue === null) { if ($pValue === null) {
return PHPExcel_Cell_DataType::TYPE_NULL; return PHPExcel_Cell_DataType::TYPE_NULL;

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Cell_Hyperlink
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Cell_Hyperlink
*
* @category PHPExcel
* @package PHPExcel_Cell
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Cell_Hyperlink class PHPExcel_Cell_Hyperlink
{ {
/** /**
@ -40,14 +32,14 @@ class PHPExcel_Cell_Hyperlink
* *
* @var string * @var string
*/ */
private $_url; private $url;
/** /**
* Tooltip to display on the hyperlink * Tooltip to display on the hyperlink
* *
* @var string * @var string
*/ */
private $_tooltip; private $tooltip;
/** /**
* Create a new PHPExcel_Cell_Hyperlink * Create a new PHPExcel_Cell_Hyperlink
@ -58,8 +50,8 @@ class PHPExcel_Cell_Hyperlink
public function __construct($pUrl = '', $pTooltip = '') public function __construct($pUrl = '', $pTooltip = '')
{ {
// Initialise member variables // Initialise member variables
$this->_url = $pUrl; $this->url = $pUrl;
$this->_tooltip = $pTooltip; $this->tooltip = $pTooltip;
} }
/** /**
@ -67,8 +59,9 @@ class PHPExcel_Cell_Hyperlink
* *
* @return string * @return string
*/ */
public function getUrl() { public function getUrl()
return $this->_url; {
return $this->url;
} }
/** /**
@ -77,8 +70,9 @@ class PHPExcel_Cell_Hyperlink
* @param string $value * @param string $value
* @return PHPExcel_Cell_Hyperlink * @return PHPExcel_Cell_Hyperlink
*/ */
public function setUrl($value = '') { public function setUrl($value = '')
$this->_url = $value; {
$this->url = $value;
return $this; return $this;
} }
@ -87,8 +81,9 @@ class PHPExcel_Cell_Hyperlink
* *
* @return string * @return string
*/ */
public function getTooltip() { public function getTooltip()
return $this->_tooltip; {
return $this->tooltip;
} }
/** /**
@ -97,8 +92,9 @@ class PHPExcel_Cell_Hyperlink
* @param string $value * @param string $value
* @return PHPExcel_Cell_Hyperlink * @return PHPExcel_Cell_Hyperlink
*/ */
public function setTooltip($value = '') { public function setTooltip($value = '')
$this->_tooltip = $value; {
$this->tooltip = $value;
return $this; return $this;
} }
@ -107,8 +103,9 @@ class PHPExcel_Cell_Hyperlink
* *
* @return boolean * @return boolean
*/ */
public function isInternal() { public function isInternal()
return strpos($this->_url, 'sheet://') !== false; {
return strpos($this->url, 'sheet://') !== false;
} }
/** /**
@ -116,11 +113,12 @@ class PHPExcel_Cell_Hyperlink
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
{
return md5( return md5(
$this->_url $this->url .
. $this->_tooltip $this->tooltip .
. __CLASS__ __CLASS__
); );
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel
* *
@ -42,5 +43,5 @@ interface PHPExcel_Cell_IValueBinder
* @param mixed $value Value to bind in cell * @param mixed $value Value to bind in cell
* @return boolean * @return boolean
*/ */
public function bindValue(PHPExcel_Cell $cell, $value = NULL); public function bindValue(PHPExcel_Cell $cell, $value = null);
} }

View File

@ -76,7 +76,7 @@ class PHPExcel_RichText_Run extends PHPExcel_RichText_TextElement implements PHP
{ {
return md5( return md5(
$this->getText() . $this->getText() .
$this->_font->getHashCode() . $this->font->getHashCode() .
__CLASS__ __CLASS__
); );
} }

View File

@ -83,7 +83,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
public function getHashCode() public function getHashCode()
{ {
return md5( return md5(
$this->_text . $this->text .
__CLASS__ __CLASS__
); );
} }

View File

@ -304,7 +304,7 @@ class PHPExcel_Settings
if (!in_array($libraryName, self::$pdfRenderers)) { if (!in_array($libraryName, self::$pdfRenderers)) {
return false; return false;
} }
self::$_pdfRendererName = $libraryName; self::$pdfRendererName = $libraryName;
return true; return true;
} }
@ -365,7 +365,7 @@ class PHPExcel_Settings
if (version_compare(PHP_VERSION, '5.2.11') >= 0) { if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); @libxml_disable_entity_loader($options == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
} }
self::$_libXmlLoaderOptions = $options; self::$libXmlLoaderOptions = $options;
} }
/** /**
@ -376,12 +376,12 @@ class PHPExcel_Settings
*/ */
public static function getLibXmlLoaderOptions() public static function getLibXmlLoaderOptions()
{ {
if (is_null(self::$_libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) { if (is_null(self::$libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) {
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR); self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
} }
if (version_compare(PHP_VERSION, '5.2.11') >= 0) { if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader(self::$libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR)); @libxml_disable_entity_loader(self::$libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
} }
return self::$_libXmlLoaderOptions; return self::$libXmlLoaderOptions;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Writer_PDF
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Writer_PDF
*
* @category PHPExcel
* @package PHPExcel_Writer_PDF
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_PDF implements PHPExcel_Writer_IWriter class PHPExcel_Writer_PDF implements PHPExcel_Writer_IWriter
{ {
@ -41,7 +33,7 @@ class PHPExcel_Writer_PDF implements PHPExcel_Writer_IWriter
* *
* @var PHPExcel_Writer_PDF_Core * @var PHPExcel_Writer_PDF_Core
*/ */
private $_renderer = NULL; private $renderer = null;
/** /**
* Instantiate a new renderer of the configured type within this container class * Instantiate a new renderer of the configured type within this container class
@ -67,7 +59,7 @@ class PHPExcel_Writer_PDF implements PHPExcel_Writer_IWriter
} }
$rendererName = 'PHPExcel_Writer_PDF_' . $pdfLibraryName; $rendererName = 'PHPExcel_Writer_PDF_' . $pdfLibraryName;
$this->_renderer = new $rendererName($phpExcel); $this->renderer = new $rendererName($phpExcel);
} }
@ -80,11 +72,11 @@ class PHPExcel_Writer_PDF implements PHPExcel_Writer_IWriter
*/ */
public function __call($name, $arguments) public function __call($name, $arguments)
{ {
if ($this->_renderer === NULL) { if ($this->renderer === null) {
throw new PHPExcel_Writer_Exception("PDF Rendering library has not been defined."); throw new PHPExcel_Writer_Exception("PDF Rendering library has not been defined.");
} }
return call_user_func_array(array($this->_renderer, $name), $arguments); return call_user_func_array(array($this->renderer, $name), $arguments);
} }
/** /**
@ -92,6 +84,6 @@ class PHPExcel_Writer_PDF implements PHPExcel_Writer_IWriter
*/ */
public function save($pFilename = null) public function save($pFilename = null)
{ {
$this->_renderer->save($pFilename); $this->renderer->save($pFilename);
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Writer_PDF_Core
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Writer_PDF_Core
*
* @category PHPExcel
* @package PHPExcel_Writer_PDF
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
{ {
/** /**
@ -54,14 +46,14 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
* *
* @var string * @var string
*/ */
protected $_orientation = NULL; protected $orientation;
/** /**
* Paper size (Over-ride) * Paper size (Over-ride)
* *
* @var int * @var int
*/ */
protected $_paperSize = NULL; protected $paperSize;
/** /**
@ -69,14 +61,14 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
* *
* @var string * @var string
*/ */
private $_saveArrayReturnType; private $saveArrayReturnType;
/** /**
* Paper Sizes xRef List * Paper Sizes xRef List
* *
* @var array * @var array
*/ */
protected static $_paperSizes = array( protected static $paperSizes = array(
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER
=> 'LETTER', // (8.5 in. by 11 in.) => 'LETTER', // (8.5 in. by 11 in.)
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_SMALL PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_SMALL
@ -219,7 +211,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
public function __construct(PHPExcel $phpExcel) public function __construct(PHPExcel $phpExcel)
{ {
parent::__construct($phpExcel); parent::__construct($phpExcel);
$this->setUseInlineCss(TRUE); $this->setUseInlineCss(true);
$this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir(); $this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
} }
@ -255,7 +247,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
*/ */
public function getPaperSize() public function getPaperSize()
{ {
return $this->_paperSize; return $this->paperSize;
} }
/** /**
@ -266,7 +258,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
*/ */
public function setPaperSize($pValue = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER) public function setPaperSize($pValue = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER)
{ {
$this->_paperSize = $pValue; $this->paperSize = $pValue;
return $this; return $this;
} }
@ -277,7 +269,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
*/ */
public function getOrientation() public function getOrientation()
{ {
return $this->_orientation; return $this->orientation;
} }
/** /**
@ -288,7 +280,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
*/ */
public function setOrientation($pValue = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT) public function setOrientation($pValue = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT)
{ {
$this->_orientation = $pValue; $this->orientation = $pValue;
return $this; return $this;
} }
@ -325,24 +317,24 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
* @param string $pFilename Name of the file to save as * @param string $pFilename Name of the file to save as
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
protected function prepareForSave($pFilename = NULL) protected function prepareForSave($pFilename = null)
{ {
// garbage collect // garbage collect
$this->_phpExcel->garbageCollect(); $this->_phpExcel->garbageCollect();
$this->_saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); $this->saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
// Open file // Open file
$fileHandle = fopen($pFilename, 'w'); $fileHandle = fopen($pFilename, 'w');
if ($fileHandle === FALSE) { if ($fileHandle === false) {
throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing."); throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing.");
} }
// Set PDF // Set PDF
$this->_isPdf = TRUE; $this->_isPdf = true;
// Build CSS // Build CSS
$this->buildCSS(TRUE); $this->buildCSS(true);
return $fileHandle; return $fileHandle;
} }
@ -358,7 +350,6 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
// Close file // Close file
fclose($fileHandle); fclose($fileHandle);
PHPExcel_Calculation::setArrayReturnType($this->_saveArrayReturnType); PHPExcel_Calculation::setArrayReturnType($this->saveArrayReturnType);
} }
} }

View File

@ -1,6 +1,15 @@
<?php <?php
/** Require DomPDF library */
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/dompdf_config.inc.php';
if (file_exists($pdfRendererClassFile)) {
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
}
/** /**
* PHPExcel * PHPExcel_Writer_PDF_DomPDF
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,23 +33,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** Require DomPDF library */
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/dompdf_config.inc.php';
if (file_exists($pdfRendererClassFile)) {
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
}
/**
* PHPExcel_Writer_PDF_DomPDF
*
* @category PHPExcel
* @package PHPExcel_Writer_PDF
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter
{ {
/** /**
@ -59,7 +51,7 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
* @param string $pFilename Name of the file to save as * @param string $pFilename Name of the file to save as
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function save($pFilename = NULL) public function save($pFilename = null)
{ {
$fileHandle = parent::prepareForSave($pFilename); $fileHandle = parent::prepareForSave($pFilename);
@ -69,21 +61,16 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
// Check for paper size and page orientation // Check for paper size and page orientation
if (is_null($this->getSheetIndex())) { if (is_null($this->getSheetIndex())) {
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
? 'L'
: 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
} else { } else {
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
? 'L'
: 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
} }
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait'; $orientation = ($orientation == 'L') ? 'landscape' : 'portrait';
// Override Page Orientation // Override Page Orientation
@ -97,8 +84,8 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
$printPaperSize = $this->getPaperSize(); $printPaperSize = $this->getPaperSize();
} }
if (isset(self::$_paperSizes[$printPaperSize])) { if (isset(self::$paperSizes[$printPaperSize])) {
$paperSize = self::$_paperSizes[$printPaperSize]; $paperSize = self::$paperSizes[$printPaperSize];
} }
@ -107,7 +94,7 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
$pdf->set_paper(strtolower($paperSize), $orientation); $pdf->set_paper(strtolower($paperSize), $orientation);
$pdf->load_html( $pdf->load_html(
$this->generateHTMLHeader(FALSE) . $this->generateHTMLHeader(false) .
$this->generateSheetData() . $this->generateSheetData() .
$this->generateHTMLFooter() $this->generateHTMLFooter()
); );
@ -118,5 +105,4 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
parent::restoreStateAfterSave($fileHandle); parent::restoreStateAfterSave($fileHandle);
} }
} }

View File

@ -1,6 +1,15 @@
<?php <?php
/** Require mPDF library */
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/mpdf.php';
if (file_exists($pdfRendererClassFile)) {
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
}
/** /**
* PHPExcel * PHPExcel_Writer_PDF_mPDF
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,23 +33,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** Require mPDF library */
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/mpdf.php';
if (file_exists($pdfRendererClassFile)) {
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
}
/**
* PHPExcel_Writer_PDF_mPDF
*
* @category PHPExcel
* @package PHPExcel_Writer_PDF
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter
{ {
/** /**
@ -59,7 +51,7 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
* @param string $pFilename Name of the file to save as * @param string $pFilename Name of the file to save as
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function save($pFilename = NULL) public function save($pFilename = null)
{ {
$fileHandle = parent::prepareForSave($pFilename); $fileHandle = parent::prepareForSave($pFilename);
@ -69,16 +61,12 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
// Check for paper size and page orientation // Check for paper size and page orientation
if (is_null($this->getSheetIndex())) { if (is_null($this->getSheetIndex())) {
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
? 'L'
: 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
} else { } else {
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
? 'L'
: 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
} }
@ -97,10 +85,11 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
$printPaperSize = $this->getPaperSize(); $printPaperSize = $this->getPaperSize();
} }
if (isset(self::$_paperSizes[$printPaperSize])) { if (isset(self::$paperSizes[$printPaperSize])) {
$paperSize = self::$_paperSizes[$printPaperSize]; $paperSize = self::$paperSizes[$printPaperSize];
} }
// Create PDF // Create PDF
$pdf = new mpdf(); $pdf = new mpdf();
$ortmp = $orientation; $ortmp = $orientation;
@ -116,7 +105,7 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
$pdf->SetCreator($this->_phpExcel->getProperties()->getCreator()); $pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
$pdf->WriteHTML( $pdf->WriteHTML(
$this->generateHTMLHeader(FALSE) . $this->generateHTMLHeader(false) .
$this->generateSheetData() . $this->generateSheetData() .
$this->generateHTMLFooter() $this->generateHTMLFooter()
); );
@ -126,5 +115,4 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
parent::restoreStateAfterSave($fileHandle); parent::restoreStateAfterSave($fileHandle);
} }
} }

View File

@ -1,6 +1,16 @@
<?php <?php
/** Require tcPDF library */
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/tcpdf.php';
if (file_exists($pdfRendererClassFile)) {
$k_path_url = PHPExcel_Settings::getPdfRendererPath();
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
}
/** /**
* PHPExcel * PHPExcel_Writer_PDF_tcPDF
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,24 +34,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** Require tcPDF library */
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/tcpdf.php';
if (file_exists($pdfRendererClassFile)) {
$k_path_url = PHPExcel_Settings::getPdfRendererPath();
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
}
/**
* PHPExcel_Writer_PDF_tcPDF
*
* @category PHPExcel
* @package PHPExcel_Writer_PDF
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter
{ {
/** /**
@ -60,7 +52,7 @@ class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPE
* @param string $pFilename Name of the file to save as * @param string $pFilename Name of the file to save as
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function save($pFilename = NULL) public function save($pFilename = null)
{ {
$fileHandle = parent::prepareForSave($pFilename); $fileHandle = parent::prepareForSave($pFilename);
@ -70,16 +62,12 @@ class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPE
// Check for paper size and page orientation // Check for paper size and page orientation
if (is_null($this->getSheetIndex())) { if (is_null($this->getSheetIndex())) {
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() $orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
? 'L'
: 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize(); $printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins(); $printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
} else { } else {
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() $orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
? 'L'
: 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize(); $printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins(); $printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
} }
@ -95,27 +83,27 @@ class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPE
$printPaperSize = $this->getPaperSize(); $printPaperSize = $this->getPaperSize();
} }
if (isset(self::$_paperSizes[$printPaperSize])) { if (isset(self::$paperSizes[$printPaperSize])) {
$paperSize = self::$_paperSizes[$printPaperSize]; $paperSize = self::$paperSizes[$printPaperSize];
} }
// Create PDF // Create PDF
$pdf = new TCPDF($orientation, 'pt', $paperSize); $pdf = new TCPDF($orientation, 'pt', $paperSize);
$pdf->setFontSubsetting(FALSE); $pdf->setFontSubsetting(false);
// Set margins, converting inches to points (using 72 dpi) // Set margins, converting inches to points (using 72 dpi)
$pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72); $pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72);
$pdf->SetAutoPageBreak(TRUE, $printMargins->getBottom() * 72); $pdf->SetAutoPageBreak(true, $printMargins->getBottom() * 72);
$pdf->setPrintHeader(FALSE); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(FALSE); $pdf->setPrintFooter(false);
$pdf->AddPage(); $pdf->AddPage();
// Set the appropriate font // Set the appropriate font
$pdf->SetFont($this->getFont()); $pdf->SetFont($this->getFont());
$pdf->writeHTML( $pdf->writeHTML(
$this->generateHTMLHeader(FALSE) . $this->generateHTMLHeader(false) .
$this->generateSheetData() . $this->generateSheetData() .
$this->generateHTMLFooter() $this->generateHTMLFooter()
); );
@ -132,5 +120,4 @@ class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPE
parent::restoreStateAfterSave($fileHandle); parent::restoreStateAfterSave($fileHandle);
} }
} }