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
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
// simple checks and initialisations
//PHPExcel_Shared_ZipStreamWrapper::register();
@ -41,7 +41,7 @@ class PHPExcel_Autoloader
* Register the Autoloader with SPL
*
*/
public static function Register()
public static function register()
{
if (function_exists('__autoload')) {
// 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
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 {
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
*/
public static function Load($pClassName)
public static function load($pClassName)
{
if ((class_exists($pClassName, false)) || (strpos($pClassName, 'PHPExcel') !== 0)) {
// Either already loaded, or not a PHPExcel class request

View File

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

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;
break;
case 1 :
$daysPerYear = (PHPExcel_Calculation_DateTime::_isLeapYear($year)) ? 366 : 365;
$daysPerYear = (PHPExcel_Calculation_DateTime::isLeapYear($year)) ? 366 : 365;
break;
default :
return PHPExcel_Calculation_Functions::NaN();
@ -397,7 +397,7 @@ class PHPExcel_Calculation_Financial {
$purchasedYear = PHPExcel_Calculation_DateTime::YEAR($purchased);
$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;
}

View File

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

View File

@ -1,6 +1,16 @@
<?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
*
@ -24,25 +34,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
/**
@ -66,16 +57,16 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
if ($dataType === PHPExcel_Cell_DataType::TYPE_STRING && !$value instanceof PHPExcel_RichText) {
// Test for booleans using locale-setting
if ($value == PHPExcel_Calculation::getTRUE()) {
$cell->setValueExplicit( TRUE, PHPExcel_Cell_DataType::TYPE_BOOL);
$cell->setValueExplicit(true, PHPExcel_Cell_DataType::TYPE_BOOL);
return true;
} elseif($value == PHPExcel_Calculation::getFALSE()) {
$cell->setValueExplicit( FALSE, PHPExcel_Cell_DataType::TYPE_BOOL);
$cell->setValueExplicit(false, PHPExcel_Cell_DataType::TYPE_BOOL);
return true;
}
// Check for number in scientific format
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;
}
@ -84,7 +75,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Convert value to number
$value = $matches[2] / $matches[3];
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
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( '??/??' );
@ -93,7 +84,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Convert value to number
$value = $matches[2] + ($matches[3] / $matches[4]);
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
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( '# ??/??' );
@ -107,7 +98,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00 );
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
return true;
}
@ -122,7 +113,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode(
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE )
str_replace('$', $currencyCode, PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_USD_SIMPLE)
);
return true;
} 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);
// Set style
$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;
}
@ -143,7 +134,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3 );
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME3);
return true;
}
@ -156,7 +147,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
$cell->setValueExplicit($days, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getNumberFormat()->setFormatCode( PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4 );
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4);
return true;
}
@ -176,12 +167,12 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
}
// Check for newline character "\n"
if (strpos($value, "\n") !== FALSE) {
if (strpos($value, "\n") !== false) {
$value = PHPExcel_Shared_String::SanitizeUTF8($value);
$cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING);
// Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() )
->getAlignment()->setWrapText(TRUE);
$cell->getWorksheet()->getStyle($cell->getCoordinate())
->getAlignment()->setWrapText(true);
return true;
}
}

View File

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

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Cell_DataValidation
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
/* Data validation types */

View File

@ -1,6 +1,16 @@
<?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
*
@ -24,25 +34,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
/**
@ -67,7 +58,7 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
}
// Set value explicit
$cell->setValueExplicit( $value, self::dataTypeForValue($value) );
$cell->setValueExplicit($value, self::dataTypeForValue($value));
// Done!
return true;
@ -79,7 +70,8 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
* @param mixed $pValue
* @return string
*/
public static function dataTypeForValue($pValue = null) {
public static function dataTypeForValue($pValue = null)
{
// Match the value against a few data types
if ($pValue === null) {
return PHPExcel_Cell_DataType::TYPE_NULL;

View File

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

View File

@ -1,4 +1,5 @@
<?php
/**
* PHPExcel
*
@ -42,5 +43,5 @@ interface PHPExcel_Cell_IValueBinder
* @param mixed $value Value to bind in cell
* @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(
$this->getText() .
$this->_font->getHashCode() .
$this->font->getHashCode() .
__CLASS__
);
}

View File

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

View File

@ -304,7 +304,7 @@ class PHPExcel_Settings
if (!in_array($libraryName, self::$pdfRenderers)) {
return false;
}
self::$_pdfRendererName = $libraryName;
self::$pdfRendererName = $libraryName;
return true;
}
@ -365,7 +365,7 @@ class PHPExcel_Settings
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@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()
{
if (is_null(self::$_libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) {
if (is_null(self::$libXmlLoaderOptions) && defined(LIBXML_DTDLOAD)) {
self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
}
if (version_compare(PHP_VERSION, '5.2.11') >= 0) {
@libxml_disable_entity_loader(self::$libXmlLoaderOptions == (LIBXML_DTDLOAD | LIBXML_DTDATTR));
}
return self::$_libXmlLoaderOptions;
return self::$libXmlLoaderOptions;
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Writer_PDF
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
@ -41,7 +33,7 @@ class PHPExcel_Writer_PDF implements PHPExcel_Writer_IWriter
*
* @var PHPExcel_Writer_PDF_Core
*/
private $_renderer = NULL;
private $renderer = null;
/**
* 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;
$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)
{
if ($this->_renderer === NULL) {
if ($this->renderer === null) {
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)
{
$this->_renderer->save($pFilename);
$this->renderer->save($pFilename);
}
}

View File

@ -1,6 +1,7 @@
<?php
/**
* PHPExcel
* PHPExcel_Writer_PDF_Core
*
* Copyright (c) 2006 - 2015 PHPExcel
*
@ -24,15 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
/**
@ -54,14 +46,14 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
*
* @var string
*/
protected $_orientation = NULL;
protected $orientation;
/**
* Paper size (Over-ride)
*
* @var int
*/
protected $_paperSize = NULL;
protected $paperSize;
/**
@ -69,14 +61,14 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
*
* @var string
*/
private $_saveArrayReturnType;
private $saveArrayReturnType;
/**
* Paper Sizes xRef List
*
* @var array
*/
protected static $_paperSizes = array(
protected static $paperSizes = array(
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER
=> 'LETTER', // (8.5 in. by 11 in.)
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)
{
parent::__construct($phpExcel);
$this->setUseInlineCss(TRUE);
$this->setUseInlineCss(true);
$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()
{
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)
{
$this->_paperSize = $pValue;
$this->paperSize = $pValue;
return $this;
}
@ -277,7 +269,7 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
*/
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)
{
$this->_orientation = $pValue;
$this->orientation = $pValue;
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
* @throws PHPExcel_Writer_Exception
*/
protected function prepareForSave($pFilename = NULL)
protected function prepareForSave($pFilename = null)
{
// garbage collect
$this->_phpExcel->garbageCollect();
$this->_saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
$this->saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
// Open file
$fileHandle = fopen($pFilename, 'w');
if ($fileHandle === FALSE) {
if ($fileHandle === false) {
throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing.");
}
// Set PDF
$this->_isPdf = TRUE;
$this->_isPdf = true;
// Build CSS
$this->buildCSS(TRUE);
$this->buildCSS(true);
return $fileHandle;
}
@ -358,7 +350,6 @@ abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
// Close file
fclose($fileHandle);
PHPExcel_Calculation::setArrayReturnType($this->_saveArrayReturnType);
PHPExcel_Calculation::setArrayReturnType($this->saveArrayReturnType);
}
}

View File

@ -1,6 +1,15 @@
<?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
*
@ -24,23 +33,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
/**
@ -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
* @throws PHPExcel_Writer_Exception
*/
public function save($pFilename = NULL)
public function save($pFilename = null)
{
$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
if (is_null($this->getSheetIndex())) {
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
? 'L'
: 'P';
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
} else {
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
? 'L'
: 'P';
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
}
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait';
// Override Page Orientation
@ -97,8 +84,8 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
$printPaperSize = $this->getPaperSize();
}
if (isset(self::$_paperSizes[$printPaperSize])) {
$paperSize = self::$_paperSizes[$printPaperSize];
if (isset(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->load_html(
$this->generateHTMLHeader(FALSE) .
$this->generateHTMLHeader(false) .
$this->generateSheetData() .
$this->generateHTMLFooter()
);
@ -118,5 +105,4 @@ class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHP
parent::restoreStateAfterSave($fileHandle);
}
}

View File

@ -1,6 +1,15 @@
<?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
*
@ -24,23 +33,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
/**
@ -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
* @throws PHPExcel_Writer_Exception
*/
public function save($pFilename = NULL)
public function save($pFilename = null)
{
$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
if (is_null($this->getSheetIndex())) {
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
? 'L'
: 'P';
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
} else {
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
? 'L'
: 'P';
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$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();
}
if (isset(self::$_paperSizes[$printPaperSize])) {
$paperSize = self::$_paperSizes[$printPaperSize];
if (isset(self::$paperSizes[$printPaperSize])) {
$paperSize = self::$paperSizes[$printPaperSize];
}
// Create PDF
$pdf = new mpdf();
$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->WriteHTML(
$this->generateHTMLHeader(FALSE) .
$this->generateHTMLHeader(false) .
$this->generateSheetData() .
$this->generateHTMLFooter()
);
@ -126,5 +115,4 @@ class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPEx
parent::restoreStateAfterSave($fileHandle);
}
}

View File

@ -1,6 +1,16 @@
<?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
*
@ -24,24 +34,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @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
{
/**
@ -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
* @throws PHPExcel_Writer_Exception
*/
public function save($pFilename = NULL)
public function save($pFilename = null)
{
$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
if (is_null($this->getSheetIndex())) {
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
? 'L'
: 'P';
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
} else {
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
? 'L'
: 'P';
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$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();
}
if (isset(self::$_paperSizes[$printPaperSize])) {
$paperSize = self::$_paperSizes[$printPaperSize];
if (isset(self::$paperSizes[$printPaperSize])) {
$paperSize = self::$paperSizes[$printPaperSize];
}
// Create PDF
$pdf = new TCPDF($orientation, 'pt', $paperSize);
$pdf->setFontSubsetting(FALSE);
$pdf->setFontSubsetting(false);
// Set margins, converting inches to points (using 72 dpi)
$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->setPrintFooter(FALSE);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->AddPage();
// Set the appropriate font
$pdf->SetFont($this->getFont());
$pdf->writeHTML(
$this->generateHTMLHeader(FALSE) .
$this->generateHTMLHeader(false) .
$this->generateSheetData() .
$this->generateHTMLFooter()
);
@ -132,5 +120,4 @@ class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPE
parent::restoreStateAfterSave($fileHandle);
}
}