mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-22 13:26:07 +03:00
More PSR-2 changes, and fixes for a couple of breakages introduced by the last commit
This commit is contained in:
parent
4f8c9bfc96
commit
b8f67c6f4d
@ -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
|
||||
|
@ -1,6 +1,16 @@
|
||||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* PHPExcel
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,7 +54,8 @@ 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));
|
||||
|
||||
@ -73,11 +64,11 @@ class PHPExcel_Calculation_Database {
|
||||
return $keys[$field-1];
|
||||
}
|
||||
$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
|
||||
* returns that subset of rows.
|
||||
@ -95,7 +86,8 @@ 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);
|
||||
|
||||
@ -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,14 +274,15 @@ 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) {
|
||||
@ -293,8 +290,10 @@ class PHPExcel_Calculation_Database {
|
||||
}
|
||||
|
||||
// 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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -43,17 +43,18 @@ if (!defined('PHPEXCEL_ROOT')) {
|
||||
* @package PHPExcel_Calculation
|
||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Calculation_DateTime {
|
||||
|
||||
class PHPExcel_Calculation_DateTime
|
||||
{
|
||||
/**
|
||||
* Identify if a year is a leap year or not
|
||||
*
|
||||
* @param integer $year The year to test
|
||||
* @return boolean TRUE if the year is a leap year, otherwise FALSE
|
||||
*/
|
||||
public static function _isLeapYear($year) {
|
||||
public static function isLeapYear($year)
|
||||
{
|
||||
return ((($year % 4) == 0) && (($year % 100) != 0) || (($year % 400) == 0));
|
||||
} // function _isLeapYear()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -68,10 +69,11 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @param boolean $methodUS Whether to use the US method or the European method of calculation
|
||||
* @return integer Number of days between the start date and the end date
|
||||
*/
|
||||
private static function _dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS) {
|
||||
private static function dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS)
|
||||
{
|
||||
if ($startDay == 31) {
|
||||
--$startDay;
|
||||
} elseif ($methodUS && ($startMonth == 2 && ($startDay == 29 || ($startDay == 28 && !self::_isLeapYear($startYear))))) {
|
||||
} elseif ($methodUS && ($startMonth == 2 && ($startDay == 29 || ($startDay == 28 && !self::isLeapYear($startYear))))) {
|
||||
$startDay = 30;
|
||||
}
|
||||
if ($endDay == 31) {
|
||||
@ -89,7 +91,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
}
|
||||
|
||||
return $endDay + $endMonth * 30 + $endYear * 360 - $startDay - $startMonth * 30 - $startYear * 360;
|
||||
} // function _dateDiff360()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -98,7 +100,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @param string $dateValue
|
||||
* @return mixed Excel date/time serial value, or string if error
|
||||
*/
|
||||
public static function _getDateValue($dateValue) {
|
||||
public static function _getDateValue($dateValue)
|
||||
{
|
||||
if (!is_numeric($dateValue)) {
|
||||
if ((is_string($dateValue)) &&
|
||||
(PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) {
|
||||
@ -114,7 +117,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
}
|
||||
}
|
||||
return $dateValue;
|
||||
} // function _getDateValue()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -123,16 +126,18 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @param string $timeValue
|
||||
* @return mixed Excel date/time serial value, or string if error
|
||||
*/
|
||||
private static function _getTimeValue($timeValue) {
|
||||
private static function _getTimeValue($timeValue)
|
||||
{
|
||||
$saveReturnDateType = PHPExcel_Calculation_Functions::getReturnDateType();
|
||||
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
||||
$timeValue = self::TIMEVALUE($timeValue);
|
||||
PHPExcel_Calculation_Functions::setReturnDateType($saveReturnDateType);
|
||||
return $timeValue;
|
||||
} // function _getTimeValue()
|
||||
}
|
||||
|
||||
|
||||
private static function _adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0) {
|
||||
private static function _adjustDateByMonths($dateValue = 0, $adjustmentMonths = 0)
|
||||
{
|
||||
// Execute function
|
||||
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
|
||||
$oMonth = (int) $PHPDateObject->format('m');
|
||||
@ -155,7 +160,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
$PHPDateObject->modify($adjustDaysString);
|
||||
}
|
||||
return $PHPDateObject;
|
||||
} // function _adjustDateByMonths()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -177,10 +182,11 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function DATETIMENOW() {
|
||||
public static function DATETIMENOW()
|
||||
{
|
||||
$saveTimeZone = date_default_timezone_get();
|
||||
date_default_timezone_set('UTC');
|
||||
$retValue = False;
|
||||
$retValue = false;
|
||||
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||
$retValue = (float) PHPExcel_Shared_Date::PHPToExcel(time());
|
||||
@ -195,7 +201,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
date_default_timezone_set($saveTimeZone);
|
||||
|
||||
return $retValue;
|
||||
} // function DATETIMENOW()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -217,10 +223,11 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function DATENOW() {
|
||||
public static function DATENOW()
|
||||
{
|
||||
$saveTimeZone = date_default_timezone_get();
|
||||
date_default_timezone_set('UTC');
|
||||
$retValue = False;
|
||||
$retValue = false;
|
||||
$excelDateTime = floor(PHPExcel_Shared_Date::PHPToExcel(time()));
|
||||
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||
@ -236,7 +243,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
date_default_timezone_set($saveTimeZone);
|
||||
|
||||
return $retValue;
|
||||
} // function DATENOW()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -289,22 +296,23 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function DATE($year = 0, $month = 1, $day = 1) {
|
||||
public static function DATE($year = 0, $month = 1, $day = 1)
|
||||
{
|
||||
$year = PHPExcel_Calculation_Functions::flattenSingleValue($year);
|
||||
$month = PHPExcel_Calculation_Functions::flattenSingleValue($month);
|
||||
$day = PHPExcel_Calculation_Functions::flattenSingleValue($day);
|
||||
|
||||
if (($month !== NULL) && (!is_numeric($month))) {
|
||||
if (($month !== null) && (!is_numeric($month))) {
|
||||
$month = PHPExcel_Shared_Date::monthStringToNumber($month);
|
||||
}
|
||||
|
||||
if (($day !== NULL) && (!is_numeric($day))) {
|
||||
if (($day !== null) && (!is_numeric($day))) {
|
||||
$day = PHPExcel_Shared_Date::dayStringToNumber($day);
|
||||
}
|
||||
|
||||
$year = ($year !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($year) : 0;
|
||||
$month = ($month !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($month) : 0;
|
||||
$day = ($day !== NULL) ? PHPExcel_Shared_String::testStringAsNumeric($day) : 0;
|
||||
$year = ($year !== null) ? PHPExcel_Shared_String::testStringAsNumeric($year) : 0;
|
||||
$month = ($month !== null) ? PHPExcel_Shared_String::testStringAsNumeric($month) : 0;
|
||||
$day = ($day !== null) ? PHPExcel_Shared_String::testStringAsNumeric($day) : 0;
|
||||
if ((!is_numeric($year)) ||
|
||||
(!is_numeric($month)) ||
|
||||
(!is_numeric($day))) {
|
||||
@ -353,7 +361,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
|
||||
return PHPExcel_Shared_Date::ExcelToPHPObject($excelDateValue);
|
||||
}
|
||||
} // function DATE()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -383,14 +391,21 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function TIME($hour = 0, $minute = 0, $second = 0) {
|
||||
public static function TIME($hour = 0, $minute = 0, $second = 0)
|
||||
{
|
||||
$hour = PHPExcel_Calculation_Functions::flattenSingleValue($hour);
|
||||
$minute = PHPExcel_Calculation_Functions::flattenSingleValue($minute);
|
||||
$second = PHPExcel_Calculation_Functions::flattenSingleValue($second);
|
||||
|
||||
if ($hour == '') { $hour = 0; }
|
||||
if ($minute == '') { $minute = 0; }
|
||||
if ($second == '') { $second = 0; }
|
||||
if ($hour == '') {
|
||||
$hour = 0;
|
||||
}
|
||||
if ($minute == '') {
|
||||
$minute = 0;
|
||||
}
|
||||
if ($second == '') {
|
||||
$second = 0;
|
||||
}
|
||||
|
||||
if ((!is_numeric($hour)) || (!is_numeric($minute)) || (!is_numeric($second))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
@ -402,7 +417,9 @@ class PHPExcel_Calculation_DateTime {
|
||||
if ($second < 0) {
|
||||
$minute += floor($second / 60);
|
||||
$second = 60 - abs($second % 60);
|
||||
if ($second == 60) { $second = 0; }
|
||||
if ($second == 60) {
|
||||
$second = 0;
|
||||
}
|
||||
} elseif ($second >= 60) {
|
||||
$minute += floor($second / 60);
|
||||
$second = $second % 60;
|
||||
@ -410,7 +427,9 @@ class PHPExcel_Calculation_DateTime {
|
||||
if ($minute < 0) {
|
||||
$hour += floor($minute / 60);
|
||||
$minute = 60 - abs($minute % 60);
|
||||
if ($minute == 60) { $minute = 0; }
|
||||
if ($minute == 60) {
|
||||
$minute = 0;
|
||||
}
|
||||
} elseif ($minute >= 60) {
|
||||
$hour += floor($minute / 60);
|
||||
$minute = $minute % 60;
|
||||
@ -438,7 +457,9 @@ class PHPExcel_Calculation_DateTime {
|
||||
if ($hour < 0) {
|
||||
$dayAdjust = floor($hour / 24);
|
||||
$hour = 24 - abs($hour % 24);
|
||||
if ($hour == 24) { $hour = 0; }
|
||||
if ($hour == 24) {
|
||||
$hour = 0;
|
||||
}
|
||||
} elseif ($hour >= 24) {
|
||||
$dayAdjust = floor($hour / 24);
|
||||
$hour = $hour % 24;
|
||||
@ -449,7 +470,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
}
|
||||
return $phpDateObject;
|
||||
}
|
||||
} // function TIME()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -478,7 +499,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function DATEVALUE($dateValue = 1) {
|
||||
public static function DATEVALUE($dateValue = 1)
|
||||
{
|
||||
$dateValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($dateValue), '"');
|
||||
// Strip any ordinals because they're allowed in Excel (English only)
|
||||
$dateValue = preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui', '$1$3', $dateValue);
|
||||
@ -492,7 +514,9 @@ class PHPExcel_Calculation_DateTime {
|
||||
if ($yearFound) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} else {
|
||||
if ($t < 100) { $t += 1900; }
|
||||
if ($t < 100) {
|
||||
$t += 1900;
|
||||
}
|
||||
$yearFound = true;
|
||||
}
|
||||
}
|
||||
@ -512,13 +536,13 @@ class PHPExcel_Calculation_DateTime {
|
||||
$dateValue = implode(' ', $t1);
|
||||
|
||||
$PHPDateArray = date_parse($dateValue);
|
||||
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
|
||||
if (($PHPDateArray === false) || ($PHPDateArray['error_count'] > 0)) {
|
||||
$testVal1 = strtok($dateValue, '- ');
|
||||
if ($testVal1 !== False) {
|
||||
if ($testVal1 !== false) {
|
||||
$testVal2 = strtok('- ');
|
||||
if ($testVal2 !== False) {
|
||||
if ($testVal2 !== false) {
|
||||
$testVal3 = strtok('- ');
|
||||
if ($testVal3 === False) {
|
||||
if ($testVal3 === false) {
|
||||
$testVal3 = strftime('%Y');
|
||||
}
|
||||
} else {
|
||||
@ -528,22 +552,38 @@ class PHPExcel_Calculation_DateTime {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
$PHPDateArray = date_parse($testVal1.'-'.$testVal2.'-'.$testVal3);
|
||||
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
|
||||
if (($PHPDateArray === false) || ($PHPDateArray['error_count'] > 0)) {
|
||||
$PHPDateArray = date_parse($testVal2.'-'.$testVal1.'-'.$testVal3);
|
||||
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
|
||||
if (($PHPDateArray === false) || ($PHPDateArray['error_count'] > 0)) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) {
|
||||
if (($PHPDateArray !== false) && ($PHPDateArray['error_count'] == 0)) {
|
||||
// Execute function
|
||||
if ($PHPDateArray['year'] == '') { $PHPDateArray['year'] = strftime('%Y'); }
|
||||
if ($PHPDateArray['year'] < 1900)
|
||||
if ($PHPDateArray['year'] == '') {
|
||||
$PHPDateArray['year'] = strftime('%Y');
|
||||
}
|
||||
if ($PHPDateArray['year'] < 1900) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
if ($PHPDateArray['month'] == '') { $PHPDateArray['month'] = strftime('%m'); }
|
||||
if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); }
|
||||
$excelDateValue = floor(PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']));
|
||||
}
|
||||
if ($PHPDateArray['month'] == '') {
|
||||
$PHPDateArray['month'] = strftime('%m');
|
||||
}
|
||||
if ($PHPDateArray['day'] == '') {
|
||||
$PHPDateArray['day'] = strftime('%d');
|
||||
}
|
||||
$excelDateValue = floor(
|
||||
PHPExcel_Shared_Date::FormattedPHPToExcel(
|
||||
$PHPDateArray['year'],
|
||||
$PHPDateArray['month'],
|
||||
$PHPDateArray['day'],
|
||||
$PHPDateArray['hour'],
|
||||
$PHPDateArray['minute'],
|
||||
$PHPDateArray['second']
|
||||
)
|
||||
);
|
||||
|
||||
switch (PHPExcel_Calculation_Functions::getReturnDateType()) {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||
@ -555,7 +595,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} // function DATEVALUE()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -580,14 +620,22 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function TIMEVALUE($timeValue) {
|
||||
public static function TIMEVALUE($timeValue)
|
||||
{
|
||||
$timeValue = trim(PHPExcel_Calculation_Functions::flattenSingleValue($timeValue), '"');
|
||||
$timeValue = str_replace(array('/', '.'), array('-', '-'), $timeValue);
|
||||
|
||||
$PHPDateArray = date_parse($timeValue);
|
||||
if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) {
|
||||
if (($PHPDateArray !== false) && ($PHPDateArray['error_count'] == 0)) {
|
||||
if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) {
|
||||
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']);
|
||||
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(
|
||||
$PHPDateArray['year'],
|
||||
$PHPDateArray['month'],
|
||||
$PHPDateArray['day'],
|
||||
$PHPDateArray['hour'],
|
||||
$PHPDateArray['minute'],
|
||||
$PHPDateArray['second']
|
||||
);
|
||||
} else {
|
||||
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(1900, 1, 1, $PHPDateArray['hour'], $PHPDateArray['minute'], $PHPDateArray['second']) - 1;
|
||||
}
|
||||
@ -596,13 +644,13 @@ class PHPExcel_Calculation_DateTime {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_EXCEL:
|
||||
return (float) $excelDateValue;
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC:
|
||||
return (integer) $phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue+25569) - 3600;;
|
||||
return (integer) $phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue+25569) - 3600;
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
|
||||
return new DateTime('1900-01-01 '.$PHPDateArray['hour'].':'.$PHPDateArray['minute'].':'.$PHPDateArray['second']);
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} // function TIMEVALUE()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -615,7 +663,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @param string $unit
|
||||
* @return integer Interval between the dates
|
||||
*/
|
||||
public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D') {
|
||||
public static function DATEDIF($startDate = 0, $endDate = 0, $unit = 'D')
|
||||
{
|
||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
$unit = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($unit));
|
||||
@ -680,7 +729,9 @@ class PHPExcel_Calculation_DateTime {
|
||||
break;
|
||||
case 'YM':
|
||||
$retVal = intval($endMonths - $startMonths);
|
||||
if ($retVal < 0) $retVal = 12 + $retVal;
|
||||
if ($retVal < 0) {
|
||||
$retVal += 12;
|
||||
}
|
||||
// We're only interested in full months
|
||||
if ($endDays < $startDays) {
|
||||
--$retVal;
|
||||
@ -694,14 +745,16 @@ class PHPExcel_Calculation_DateTime {
|
||||
$endYears = $PHPEndDateObject->format('Y');
|
||||
}
|
||||
$retVal = $PHPEndDateObject->format('z') - $PHPStartDateObject->format('z');
|
||||
if ($retVal < 0) { $retVal += 365; }
|
||||
if ($retVal < 0) {
|
||||
$retVal += 365;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$retVal = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
return $retVal;
|
||||
} // function DATEDIF()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -733,7 +786,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* same month.
|
||||
* @return integer Number of days between start date and end date
|
||||
*/
|
||||
public static function DAYS360($startDate = 0, $endDate = 0, $method = false) {
|
||||
public static function DAYS360($startDate = 0, $endDate = 0, $method = false)
|
||||
{
|
||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
|
||||
@ -759,8 +813,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
$endMonth = $PHPEndDateObject->format('n');
|
||||
$endYear = $PHPEndDateObject->format('Y');
|
||||
|
||||
return self::_dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, !$method);
|
||||
} // function DAYS360()
|
||||
return self::dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, !$method);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -788,7 +842,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* 4 European 30/360
|
||||
* @return float fraction of the year
|
||||
*/
|
||||
public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) {
|
||||
public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0)
|
||||
{
|
||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
$method = PHPExcel_Calculation_Functions::flattenSingleValue($method);
|
||||
@ -811,7 +866,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
$years = $endYear - $startYear + 1;
|
||||
$leapDays = 0;
|
||||
if ($years == 1) {
|
||||
if (self::_isLeapYear($endYear)) {
|
||||
if (self::isLeapYear($endYear)) {
|
||||
$startMonth = self::MONTHOFYEAR($startDate);
|
||||
$endMonth = self::MONTHOFYEAR($endDate);
|
||||
$endDay = self::DAYOFMONTH($endDate);
|
||||
@ -826,20 +881,20 @@ class PHPExcel_Calculation_DateTime {
|
||||
$startMonth = self::MONTHOFYEAR($startDate);
|
||||
$startDay = self::DAYOFMONTH($startDate);
|
||||
if ($startMonth < 3) {
|
||||
$leapDays += (self::_isLeapYear($year)) ? 1 : 0;
|
||||
$leapDays += (self::isLeapYear($year)) ? 1 : 0;
|
||||
}
|
||||
} elseif ($year == $endYear) {
|
||||
$endMonth = self::MONTHOFYEAR($endDate);
|
||||
$endDay = self::DAYOFMONTH($endDate);
|
||||
if (($endMonth * 100 + $endDay) >= (2 * 100 + 29)) {
|
||||
$leapDays += (self::_isLeapYear($year)) ? 1 : 0;
|
||||
$leapDays += (self::isLeapYear($year)) ? 1 : 0;
|
||||
}
|
||||
} else {
|
||||
$leapDays += (self::_isLeapYear($year)) ? 1 : 0;
|
||||
$leapDays += (self::isLeapYear($year)) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
if ($years == 2) {
|
||||
if (($leapDays == 0) && (self::_isLeapYear($startYear)) && ($days > 365)) {
|
||||
if (($leapDays == 0) && (self::isLeapYear($startYear)) && ($days > 365)) {
|
||||
$leapDays = 1;
|
||||
} elseif ($days < 366) {
|
||||
$years = 1;
|
||||
@ -853,11 +908,11 @@ class PHPExcel_Calculation_DateTime {
|
||||
case 3:
|
||||
return self::DATEDIF($startDate, $endDate) / 365;
|
||||
case 4:
|
||||
return self::DAYS360($startDate,$endDate,True) / 360;
|
||||
return self::DAYS360($startDate, $endDate, true) / 360;
|
||||
}
|
||||
}
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
} // function YEARFRAC()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -883,7 +938,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* as state and federal holidays and floating holidays.
|
||||
* @return integer Interval between the dates
|
||||
*/
|
||||
public static function NETWORKDAYS($startDate,$endDate) {
|
||||
public static function NETWORKDAYS($startDate, $endDate)
|
||||
{
|
||||
// Retrieve the mandatory start and end date that are referenced in the function definition
|
||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDate = PHPExcel_Calculation_Functions::flattenSingleValue($endDate);
|
||||
@ -909,9 +965,13 @@ class PHPExcel_Calculation_DateTime {
|
||||
|
||||
// Execute function
|
||||
$startDoW = 6 - self::DAYOFWEEK($startDate, 2);
|
||||
if ($startDoW < 0) { $startDoW = 0; }
|
||||
if ($startDoW < 0) {
|
||||
$startDoW = 0;
|
||||
}
|
||||
$endDoW = self::DAYOFWEEK($endDate, 2);
|
||||
if ($endDoW >= 6) { $endDoW = 0; }
|
||||
if ($endDoW >= 6) {
|
||||
$endDoW = 0;
|
||||
}
|
||||
|
||||
$wholeWeekDays = floor(($endDate - $startDate) / 7) * 5;
|
||||
$partWeekDays = $endDoW + $startDoW;
|
||||
@ -937,7 +997,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
return 0 - ($wholeWeekDays + $partWeekDays);
|
||||
}
|
||||
return $wholeWeekDays + $partWeekDays;
|
||||
} // function NETWORKDAYS()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -965,7 +1025,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function WORKDAY($startDate,$endDays) {
|
||||
public static function WORKDAY($startDate, $endDays)
|
||||
{
|
||||
// Retrieve the mandatory start date and days that are referenced in the function definition
|
||||
$startDate = PHPExcel_Calculation_Functions::flattenSingleValue($startDate);
|
||||
$endDays = PHPExcel_Calculation_Functions::flattenSingleValue($endDays);
|
||||
@ -980,9 +1041,11 @@ class PHPExcel_Calculation_DateTime {
|
||||
$startDate = (float) floor($startDate);
|
||||
$endDays = (int) floor($endDays);
|
||||
// If endDays is 0, we always return startDate
|
||||
if ($endDays == 0) { return $startDate; }
|
||||
if ($endDays == 0) {
|
||||
return $startDate;
|
||||
}
|
||||
|
||||
$decrementing = ($endDays < 0) ? True : False;
|
||||
$decrementing = ($endDays < 0) ? true : false;
|
||||
|
||||
// Adjust the start date if it falls over a weekend
|
||||
|
||||
@ -1005,7 +1068,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
if (!empty($dateArgs)) {
|
||||
$holidayCountedArray = $holidayDates = array();
|
||||
foreach ($dateArgs as $holidayDate) {
|
||||
if (($holidayDate !== NULL) && (trim($holidayDate) > '')) {
|
||||
if (($holidayDate !== null) && (trim($holidayDate) > '')) {
|
||||
if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
|
||||
return PHPExcel_Calculation_Functions::VALUE();
|
||||
}
|
||||
@ -1040,7 +1103,6 @@ class PHPExcel_Calculation_DateTime {
|
||||
if ($endDoW >= 5) {
|
||||
$endDate += ($decrementing) ? -$endDoW + 4 : 7 - $endDoW;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1052,7 +1114,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
|
||||
return PHPExcel_Shared_Date::ExcelToPHPObject($endDate);
|
||||
}
|
||||
} // function WORKDAY()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1068,7 +1130,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @return int Day of the month
|
||||
*/
|
||||
public static function DAYOFMONTH($dateValue = 1) {
|
||||
public static function DAYOFMONTH($dateValue = 1)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
|
||||
if ($dateValue === null) {
|
||||
@ -1085,7 +1148,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
|
||||
|
||||
return (int) $PHPDateObject->format('j');
|
||||
} // function DAYOFMONTH()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1105,7 +1168,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* 3 Numbers 0 (Monday) through 6 (Sunday).
|
||||
* @return int Day of the week value
|
||||
*/
|
||||
public static function DAYOFWEEK($dateValue = 1, $style = 1) {
|
||||
public static function DAYOFWEEK($dateValue = 1, $style = 1)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$style = PHPExcel_Calculation_Functions::flattenSingleValue($style);
|
||||
|
||||
@ -1130,11 +1194,18 @@ class PHPExcel_Calculation_DateTime {
|
||||
|
||||
$firstDay = 1;
|
||||
switch ($style) {
|
||||
case 1: ++$DoW;
|
||||
case 1:
|
||||
++$DoW;
|
||||
break;
|
||||
case 2: if ($DoW == 0) { $DoW = 7; }
|
||||
case 2:
|
||||
if ($DoW == 0) {
|
||||
$DoW = 7;
|
||||
}
|
||||
break;
|
||||
case 3: if ($DoW == 0) { $DoW = 7; }
|
||||
case 3:
|
||||
if ($DoW == 0) {
|
||||
$DoW = 7;
|
||||
}
|
||||
$firstDay = 0;
|
||||
--$DoW;
|
||||
break;
|
||||
@ -1150,7 +1221,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
}
|
||||
|
||||
return (int) $DoW;
|
||||
} // function DAYOFWEEK()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1173,7 +1244,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* 2 Week begins on Monday.
|
||||
* @return int Week Number
|
||||
*/
|
||||
public static function WEEKOFYEAR($dateValue = 1, $method = 1) {
|
||||
public static function WEEKOFYEAR($dateValue = 1, $method = 1)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$method = PHPExcel_Calculation_Functions::flattenSingleValue($method);
|
||||
|
||||
@ -1203,7 +1275,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
$weekOfYear = ceil($dayOfYear / 7) + 1;
|
||||
|
||||
return (int) $weekOfYear;
|
||||
} // function WEEKOFYEAR()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1219,7 +1291,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @return int Month of the year
|
||||
*/
|
||||
public static function MONTHOFYEAR($dateValue = 1) {
|
||||
public static function MONTHOFYEAR($dateValue = 1)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
|
||||
if ($dateValue === null) {
|
||||
@ -1234,7 +1307,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
|
||||
|
||||
return (int) $PHPDateObject->format('n');
|
||||
} // function MONTHOFYEAR()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1250,7 +1323,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* PHP DateTime object, or a standard date string
|
||||
* @return int Year
|
||||
*/
|
||||
public static function YEAR($dateValue = 1) {
|
||||
public static function YEAR($dateValue = 1)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
|
||||
if ($dateValue === null) {
|
||||
@ -1265,7 +1339,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
|
||||
|
||||
return (int) $PHPDateObject->format('Y');
|
||||
} // function YEAR()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1281,7 +1355,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* PHP DateTime object, or a standard time string
|
||||
* @return int Hour
|
||||
*/
|
||||
public static function HOUROFDAY($timeValue = 0) {
|
||||
public static function HOUROFDAY($timeValue = 0)
|
||||
{
|
||||
$timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue);
|
||||
|
||||
if (!is_numeric($timeValue)) {
|
||||
@ -1305,7 +1380,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
|
||||
|
||||
return (int) gmdate('G', $timeValue);
|
||||
} // function HOUROFDAY()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1321,7 +1396,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* PHP DateTime object, or a standard time string
|
||||
* @return int Minute
|
||||
*/
|
||||
public static function MINUTEOFHOUR($timeValue = 0) {
|
||||
public static function MINUTEOFHOUR($timeValue = 0)
|
||||
{
|
||||
$timeValue = $timeTester = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue);
|
||||
|
||||
if (!is_numeric($timeValue)) {
|
||||
@ -1345,7 +1421,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
|
||||
|
||||
return (int) gmdate('i', $timeValue);
|
||||
} // function MINUTEOFHOUR()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1361,7 +1437,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* PHP DateTime object, or a standard time string
|
||||
* @return int Second
|
||||
*/
|
||||
public static function SECONDOFMINUTE($timeValue = 0) {
|
||||
public static function SECONDOFMINUTE($timeValue = 0)
|
||||
{
|
||||
$timeValue = PHPExcel_Calculation_Functions::flattenSingleValue($timeValue);
|
||||
|
||||
if (!is_numeric($timeValue)) {
|
||||
@ -1385,7 +1462,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
|
||||
|
||||
return (int) gmdate('s', $timeValue);
|
||||
} // function SECONDOFMINUTE()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1407,7 +1484,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function EDATE($dateValue = 1, $adjustmentMonths = 0) {
|
||||
public static function EDATE($dateValue = 1, $adjustmentMonths = 0)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths);
|
||||
|
||||
@ -1431,7 +1509,7 @@ class PHPExcel_Calculation_DateTime {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
|
||||
return $PHPDateObject;
|
||||
}
|
||||
} // function EDATE()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1452,7 +1530,8 @@ class PHPExcel_Calculation_DateTime {
|
||||
* @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object,
|
||||
* depending on the value of the ReturnDateType flag
|
||||
*/
|
||||
public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0) {
|
||||
public static function EOMONTH($dateValue = 1, $adjustmentMonths = 0)
|
||||
{
|
||||
$dateValue = PHPExcel_Calculation_Functions::flattenSingleValue($dateValue);
|
||||
$adjustmentMonths = PHPExcel_Calculation_Functions::flattenSingleValue($adjustmentMonths);
|
||||
|
||||
@ -1479,7 +1558,5 @@ class PHPExcel_Calculation_DateTime {
|
||||
case PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT:
|
||||
return $PHPDateObject;
|
||||
}
|
||||
} // function EOMONTH()
|
||||
|
||||
} // class PHPExcel_Calculation_DateTime
|
||||
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHPExcel_Calculation_Token_Stack
|
||||
*
|
||||
|
@ -1,6 +1,16 @@
|
||||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* PHPExcel
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,10 +57,10 @@ 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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
->getAlignment()->setWrapText(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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!';
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -1,6 +1,16 @@
|
||||
<?php
|
||||
|
||||
/** PHPExcel root directory */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* PHPExcel
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
/**
|
||||
@ -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;
|
||||
|
@ -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__
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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__
|
||||
);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class PHPExcel_RichText_TextElement implements PHPExcel_RichText_ITextElement
|
||||
public function getHashCode()
|
||||
{
|
||||
return md5(
|
||||
$this->_text .
|
||||
$this->text .
|
||||
__CLASS__
|
||||
);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user