upgrade to PHPExcel 1.7.2
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -21,9 +21,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Style/NumberFormat.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Date
|
||||
{
|
||||
@@ -106,12 +106,15 @@ class PHPExcel_Shared_Date
|
||||
// Perform conversion
|
||||
if ($dateValue >= 1) {
|
||||
$utcDays = $dateValue - $myExcelBaseDate;
|
||||
$returnValue = (integer) round($utcDays * 24 * 60 * 60);
|
||||
$returnValue = round($utcDays * 24 * 60 * 60);
|
||||
if (($returnValue <= PHP_INT_MAX) && ($returnValue >= -PHP_INT_MAX)) {
|
||||
$returnValue = (integer) $returnValue;
|
||||
}
|
||||
} else {
|
||||
$hours = round($dateValue * 24);
|
||||
$mins = round($dateValue * 24 * 60) - round($hours * 60);
|
||||
$secs = round($dateValue * 24 * 60 * 60) - round($hours * 60 * 60) - round($mins * 60);
|
||||
$returnValue = (integer) mktime($hours, $mins, $secs);
|
||||
$returnValue = (integer) gmmktime($hours, $mins, $secs);
|
||||
}
|
||||
|
||||
// Return
|
||||
@@ -132,8 +135,10 @@ class PHPExcel_Shared_Date
|
||||
$hours = round($time / 3600);
|
||||
$minutes = round($time / 60) - ($hours * 60);
|
||||
$seconds = round($time) - ($hours * 3600) - ($minutes * 60);
|
||||
|
||||
$dateObj = date_create('1-Jan-1970+'.$days.' days');
|
||||
$dateObj->setTime($hours,$minutes,$seconds);
|
||||
|
||||
return $dateObj;
|
||||
} // function ExcelToPHPObject()
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,18 +20,30 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Shared_String */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Drawing
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Drawing
|
||||
{
|
||||
@@ -60,33 +72,67 @@ class PHPExcel_Shared_Drawing
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to cell dimension. Exact algorithm not known.
|
||||
* Convert pixels to column width. Exact algorithm not known.
|
||||
* By inspection of a real Excel file using Calibri 11, one finds 1000px ~ 142.85546875
|
||||
* This gives a conversion factor of 7. Also, we assume that pixels and font size are proportional.
|
||||
*
|
||||
* @param int $pValue Value in pixels
|
||||
* @param int $pFontSize Default font size of workbook
|
||||
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
||||
* @return int Value in cell dimension
|
||||
*/
|
||||
public static function pixelsToCellDimension($pValue = 0, $pFontSize = 11) {
|
||||
return $pValue * $pFontSize / 11 / 7;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert cell width to pixels
|
||||
*
|
||||
* @param int $pValue Value in cell dimension
|
||||
* @param int $pFontSize Default font size of workbook
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function cellDimensionToPixels($pValue = 0, $pFontSize = 11) {
|
||||
if ($pValue != 0) {
|
||||
return $pValue * 7 * $pFontSize / 11;
|
||||
public static function pixelsToCellDimension($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
|
||||
// Font name and size
|
||||
$name = $pDefaultFont->getName();
|
||||
$size = $pDefaultFont->getSize();
|
||||
|
||||
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
||||
// Exact width can be determined
|
||||
$colWidth = $pValue
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px'];
|
||||
} else {
|
||||
return 0;
|
||||
// We don't have data for this particular font and size, use approximation by
|
||||
// extrapolating from Calibri 11
|
||||
$colWidth = $pValue * 11
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px'] / $size;
|
||||
}
|
||||
|
||||
return $colWidth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert column width from (intrinsic) Excel units to pixels
|
||||
*
|
||||
* @param float $pValue Value in cell dimension
|
||||
* @param PHPExcel_Style_Font $pDefaultFont Default font of the workbook
|
||||
* @return int Value in pixels
|
||||
*/
|
||||
public static function cellDimensionToPixels($pValue = 0, PHPExcel_Style_Font $pDefaultFont) {
|
||||
// Font name and size
|
||||
$name = $pDefaultFont->getName();
|
||||
$size = $pDefaultFont->getSize();
|
||||
|
||||
if (isset(PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size])) {
|
||||
// Exact width can be determined
|
||||
$colWidth = $pValue
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['px']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths[$name][$size]['width'];
|
||||
|
||||
} else {
|
||||
// We don't have data for this particular font and size, use approximation by
|
||||
// extrapolating from Calibri 11
|
||||
$colWidth = $pValue * $size
|
||||
* PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['px']
|
||||
/ PHPExcel_Shared_Font::$defaultColumnWidths['Calibri'][11]['width'] / 11;
|
||||
}
|
||||
|
||||
// Round pixels to closest integer
|
||||
$colWidth = (int) round($colWidth);
|
||||
|
||||
return $colWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pixels to points
|
||||
*
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Escher
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
@@ -39,12 +39,15 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Cell.php';
|
||||
/** PHPExcel_Shared_Drawing */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Drawing.php';
|
||||
|
||||
/** PHPExcel_Shared_Font */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/Font.php';
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Excel5
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Excel5
|
||||
{
|
||||
@@ -59,8 +62,8 @@ class PHPExcel_Shared_Excel5
|
||||
*/
|
||||
public static function sizeCol($sheet, $col = 'A')
|
||||
{
|
||||
// default font size of workbook
|
||||
$fontSize = $sheet->getParent()->getDefaultStyle()->getFont()->getSize();
|
||||
// default font of the workbook
|
||||
$font = $sheet->getParent()->getDefaultStyle()->getFont();
|
||||
|
||||
$columnDimensions = $sheet->getColumnDimensions();
|
||||
|
||||
@@ -70,17 +73,19 @@ class PHPExcel_Shared_Excel5
|
||||
// then we have column dimension with explicit width
|
||||
$columnDimension = $columnDimensions[$col];
|
||||
$width = $columnDimension->getWidth();
|
||||
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $fontSize);
|
||||
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
|
||||
|
||||
} else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
|
||||
|
||||
// then we have default column dimension with explicit width
|
||||
$defaultColumnDimension = $sheet->getDefaultColumnDimension();
|
||||
$width = $defaultColumnDimension->getWidth();
|
||||
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $fontSize);
|
||||
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
|
||||
|
||||
} else {
|
||||
$pixelWidth = (int) 64 * $fontSize / 11; // here we interpolate from Calibri 11
|
||||
|
||||
// we don't even have any default column dimension. Width depends on default font
|
||||
$pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true);
|
||||
}
|
||||
|
||||
// now find the effective column width in pixels
|
||||
@@ -104,6 +109,9 @@ class PHPExcel_Shared_Excel5
|
||||
*/
|
||||
public static function sizeRow($sheet, $row = 1)
|
||||
{
|
||||
// default font of the workbook
|
||||
$font = $sheet->getParent()->getDefaultStyle()->getFont();
|
||||
|
||||
$rowDimensions = $sheet->getRowDimensions();
|
||||
|
||||
// first find the true row height in pixels (uncollapsed and unhidden)
|
||||
@@ -122,7 +130,11 @@ class PHPExcel_Shared_Excel5
|
||||
$pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight);
|
||||
|
||||
} else {
|
||||
$pixelRowHeight = 20; // here we assume Calibri 11
|
||||
|
||||
// we don't even have any default row dimension. Height depends on default font
|
||||
$pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font);
|
||||
$pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight);
|
||||
|
||||
}
|
||||
|
||||
// now find the effective row height in pixels
|
||||
@@ -301,8 +313,8 @@ class PHPExcel_Shared_Excel5
|
||||
// Convert the pixel values to the percentage value expected by Excel
|
||||
$x1 = $x1 / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_start)) * 1024;
|
||||
$y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256;
|
||||
$x2 = $width / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object
|
||||
$y2 = $height / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object
|
||||
$x2 = ($width + 1) / self::sizeCol($sheet, PHPExcel_Cell::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object
|
||||
$y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object
|
||||
|
||||
$startCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_start) . ($row_start + 1);
|
||||
$endCoordinates = PHPExcel_Cell::stringFromColumnIndex($col_end) . ($row_end + 1);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_File
|
||||
{
|
||||
@@ -79,7 +79,7 @@ class PHPExcel_Shared_File
|
||||
|
||||
// Found something?
|
||||
if ($returnValue == '' || is_null($returnValue)) {
|
||||
$pathArray = split('/' , $pFilename);
|
||||
$pathArray = explode('/' , $pFilename);
|
||||
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
|
||||
for ($i = 0; $i < count($pathArray); ++$i) {
|
||||
if ($pathArray[$i] == '..' && $i > 0) {
|
||||
@@ -95,4 +95,42 @@ class PHPExcel_Shared_File
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the systems temporary directory.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function sys_get_temp_dir()
|
||||
{
|
||||
// sys_get_temp_dir is only available since PHP 5.2.1
|
||||
// http://php.net/manual/en/function.sys-get-temp-dir.php#94119
|
||||
|
||||
if ( !function_exists('sys_get_temp_dir')) {
|
||||
if( $temp = getenv('TMP') ) {
|
||||
return realpath($temp);
|
||||
}
|
||||
if( $temp = getenv('TEMP') ) {
|
||||
return realpath($temp);
|
||||
}
|
||||
if( $temp = getenv('TMPDIR') ) {
|
||||
return realpath($temp);
|
||||
}
|
||||
|
||||
// trick for creating a file in system's temporary dir
|
||||
// without knowing the path of the system's temporary dir
|
||||
$temp = tempnam(__FILE__, '');
|
||||
if (file_exists($temp)) {
|
||||
unlink($temp);
|
||||
return realpath(dirname($temp));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
// use ordinary built-in PHP function
|
||||
return realpath(sys_get_temp_dir());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,21 +20,37 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
/** PHPExcel root */
|
||||
if (!defined('PHPEXCEL_ROOT')) {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||
}
|
||||
|
||||
/** PHPExcel_Shared_String */
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Font
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_Font
|
||||
{
|
||||
/* Methods for resolving autosize value */
|
||||
const AUTOSIZE_METHOD_APPROX = 'approx';
|
||||
const AUTOSIZE_METHOD_EXACT = 'exact';
|
||||
|
||||
/** Character set codes used by BIFF5-8 in Font records */
|
||||
const CHARSET_ANSI_LATIN = 0x00;
|
||||
const CHARSET_SYSTEM_DEFAULT = 0x01;
|
||||
@@ -56,6 +72,175 @@ class PHPExcel_Shared_Font
|
||||
const CHARSET_ANSI_LATIN_II = 0xEE;
|
||||
const CHARSET_OEM_LATIN_I = 0xFF;
|
||||
|
||||
// XXX: Constants created!
|
||||
/** Font filenames */
|
||||
const ARIAL = 'arial.ttf';
|
||||
const ARIAL_BOLD = 'arialbd.ttf';
|
||||
const ARIAL_ITALIC = 'ariali.ttf';
|
||||
const ARIAL_BOLD_ITALIC = 'arialbi.ttf';
|
||||
|
||||
const CALIBRI = 'CALIBRI.TTF';
|
||||
const CALIBRI_BOLD = 'CALIBRIB.TTF';
|
||||
const CALIBRI_ITALIC = 'CALIBRII.TTF';
|
||||
const CALIBRI_BOLD_ITALIC = 'CALIBRIZ.TTF';
|
||||
|
||||
const COMIC_SANS_MS = 'comic.ttf';
|
||||
const COMIC_SANS_MS_BOLD = 'comicbd.ttf';
|
||||
|
||||
const COURIER_NEW = 'cour.ttf';
|
||||
const COURIER_NEW_BOLD = 'courbd.ttf';
|
||||
const COURIER_NEW_ITALIC = 'couri.ttf';
|
||||
const COURIER_NEW_BOLD_ITALIC = 'courbi.ttf';
|
||||
|
||||
const GEORGIA = 'georgia.ttf';
|
||||
const GEORGIA_BOLD = 'georgiab.ttf';
|
||||
const GEORGIA_ITALIC = 'georgiai.ttf';
|
||||
const GEORGIA_BOLD_ITALIC = 'georgiaz.ttf';
|
||||
|
||||
const IMPACT = 'impact.ttf';
|
||||
|
||||
const LIBERATION_SANS = 'LiberationSans-Regular.ttf';
|
||||
const LIBERATION_SANS_BOLD = 'LiberationSans-Bold.ttf';
|
||||
const LIBERATION_SANS_ITALIC = 'LiberationSans-Italic.ttf';
|
||||
const LIBERATION_SANS_BOLD_ITALIC = 'LiberationSans-BoldItalic.ttf';
|
||||
|
||||
const LUCIDA_CONSOLE = 'lucon.ttf';
|
||||
const LUCIDA_SANS_UNICODE = 'l_10646.ttf';
|
||||
|
||||
const MICROSOFT_SANS_SERIF = 'micross.ttf';
|
||||
|
||||
const PALATINO_LINOTYPE = 'pala.ttf';
|
||||
const PALATINO_LINOTYPE_BOLD = 'palab.ttf';
|
||||
const PALATINO_LINOTYPE_ITALIC = 'palai.ttf';
|
||||
const PALATINO_LINOTYPE_BOLD_ITALIC = 'palabi.ttf';
|
||||
|
||||
const SYMBOL = 'symbol.ttf';
|
||||
|
||||
const TAHOMA = 'tahoma.ttf';
|
||||
const TAHOMA_BOLD = 'tahomabd.ttf';
|
||||
|
||||
const TIMES_NEW_ROMAN = 'times.ttf';
|
||||
const TIMES_NEW_ROMAN_BOLD = 'timesbd.ttf';
|
||||
const TIMES_NEW_ROMAN_ITALIC = 'timesi.ttf';
|
||||
const TIMES_NEW_ROMAN_BOLD_ITALIC = 'timesbi.ttf';
|
||||
|
||||
const TREBUCHET_MS = 'trebuc.ttf';
|
||||
const TREBUCHET_MS_BOLD = 'trebucbd.ttf';
|
||||
const TREBUCHET_MS_ITALIC = 'trebucit.ttf';
|
||||
const TREBUCHET_MS_BOLD_ITALIC = 'trebucbi.ttf';
|
||||
|
||||
const VERDANA = 'verdana.ttf';
|
||||
const VERDANA_BOLD = 'verdanab.ttf';
|
||||
const VERDANA_ITALIC = 'verdanai.ttf';
|
||||
const VERDANA_BOLD_ITALIC = 'verdanaz.ttf';
|
||||
|
||||
/**
|
||||
* AutoSize method
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $autoSizeMethod = self::AUTOSIZE_METHOD_APPROX;
|
||||
|
||||
/**
|
||||
* Path to folder containing TrueType font .ttf files
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $trueTypeFontPath = null;
|
||||
|
||||
/**
|
||||
* How wide is a default column for a given default font and size?
|
||||
* Empirical data found by inspecting real Excel files and reading off the pixel width
|
||||
* in Microsoft Office Excel 2007.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $defaultColumnWidths = array(
|
||||
'Arial' => array(
|
||||
1 => array('px' => 24, 'width' => 12.00000000),
|
||||
2 => array('px' => 24, 'width' => 12.00000000),
|
||||
3 => array('px' => 32, 'width' => 10.66406250),
|
||||
4 => array('px' => 32, 'width' => 10.66406250),
|
||||
5 => array('px' => 40, 'width' => 10.00000000),
|
||||
6 => array('px' => 48, 'width' => 9.59765625),
|
||||
7 => array('px' => 48, 'width' => 9.59765625),
|
||||
8 => array('px' => 56, 'width' => 9.33203125),
|
||||
9 => array('px' => 64, 'width' => 9.14062500),
|
||||
10 => array('px' => 64, 'width' => 9.14062500),
|
||||
),
|
||||
'Calibri' => array(
|
||||
1 => array('px' => 24, 'width' => 12.00000000),
|
||||
2 => array('px' => 24, 'width' => 12.00000000),
|
||||
3 => array('px' => 32, 'width' => 10.66406250),
|
||||
4 => array('px' => 32, 'width' => 10.66406250),
|
||||
5 => array('px' => 40, 'width' => 10.00000000),
|
||||
6 => array('px' => 48, 'width' => 9.59765625),
|
||||
7 => array('px' => 48, 'width' => 9.59765625),
|
||||
8 => array('px' => 56, 'width' => 9.33203125),
|
||||
9 => array('px' => 56, 'width' => 9.33203125),
|
||||
10 => array('px' => 64, 'width' => 9.14062500),
|
||||
11 => array('px' => 64, 'width' => 9.14062500),
|
||||
),
|
||||
'Verdana' => array(
|
||||
1 => array('px' => 24, 'width' => 12.00000000),
|
||||
2 => array('px' => 24, 'width' => 12.00000000),
|
||||
3 => array('px' => 32, 'width' => 10.66406250),
|
||||
4 => array('px' => 32, 'width' => 10.66406250),
|
||||
5 => array('px' => 40, 'width' => 10.00000000),
|
||||
6 => array('px' => 48, 'width' => 9.59765625),
|
||||
7 => array('px' => 48, 'width' => 9.59765625),
|
||||
8 => array('px' => 64, 'width' => 9.14062500),
|
||||
9 => array('px' => 72, 'width' => 9.00000000),
|
||||
10 => array('px' => 72, 'width' => 9.00000000),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Set autoSize method
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public static function setAutoSizeMethod($pValue = 'approx')
|
||||
{
|
||||
self::$autoSizeMethod = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get autoSize method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getAutoSizeMethod()
|
||||
{
|
||||
return self::$autoSizeMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the path to the folder containing .ttf files. There should be a trailing slash.
|
||||
* Typical locations on variout some platforms:
|
||||
* <ul>
|
||||
* <li>C:/Windows/Fonts/</li>
|
||||
* <li>/usr/share/fonts/truetype/</li>
|
||||
* <li>~/.fonts/</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param string $pValue
|
||||
*/
|
||||
public static function setTrueTypeFontPath($pValue = '')
|
||||
{
|
||||
self::$trueTypeFontPath = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the folder containing .ttf files.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getTrueTypeFontPath()
|
||||
{
|
||||
return self::$trueTypeFontPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) OpenXML column width, based on font size and text contained
|
||||
*
|
||||
@@ -65,29 +250,120 @@ class PHPExcel_Shared_Font
|
||||
* @param int $rotation Rotation angle
|
||||
* @return int Column width
|
||||
*/
|
||||
public static function calculateColumnWidth($fontSize = 9, $fontSizeInPixels = false, $columnText = '', $rotation = 0) {
|
||||
if (!$fontSizeInPixels) {
|
||||
// Translate points size to pixel size
|
||||
$fontSize = PHPExcel_Shared_Font::fontSizeToPixels($fontSize);
|
||||
}
|
||||
|
||||
// If it is rich text, use rich text...
|
||||
public static function calculateColumnWidth(PHPExcel_Style_Font $font, $columnText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) {
|
||||
|
||||
// If it is rich text, use plain text
|
||||
if ($columnText instanceof PHPExcel_RichText) {
|
||||
$columnText = $columnText->getPlainText();
|
||||
}
|
||||
|
||||
// Only measure the part before the first newline character
|
||||
if (strpos($columnText, "\r") !== false) {
|
||||
$columnText = substr($columnText, 0, strpos($columnText, "\r"));
|
||||
}
|
||||
|
||||
// Only measure the part before the first newline character (is always "\n")
|
||||
if (strpos($columnText, "\n") !== false) {
|
||||
$columnText = substr($columnText, 0, strpos($columnText, "\n"));
|
||||
}
|
||||
|
||||
// Try to get the exact text width in pixels
|
||||
try {
|
||||
// If autosize method is set to 'approx', use approximation
|
||||
if (self::$autoSizeMethod == self::AUTOSIZE_METHOD_APPROX) {
|
||||
throw new Exception('AutoSize method is set to approx');
|
||||
}
|
||||
|
||||
// Width of text in pixels excl. padding
|
||||
$columnWidth = self::getTextWidthPixelsExact($columnText, $font, $rotation);
|
||||
|
||||
// Excel adds some padding, use 1.07 of the width of an 'n' glyph
|
||||
$columnWidth += ceil(self::getTextWidthPixelsExact('0', $font, 0) * 1.07); // pixels incl. padding
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Width of text in pixels excl. padding, approximation
|
||||
$columnWidth = self::getTextWidthPixelsApprox($columnText, $font, $rotation);
|
||||
|
||||
// Excel adds some padding, just use approx width of 'n' glyph
|
||||
$columnWidth += self::getTextWidthPixelsApprox('n', $font, 0);
|
||||
}
|
||||
|
||||
// Convert from pixel width to column width
|
||||
$columnWidth = PHPExcel_Shared_Drawing::pixelsToCellDimension($columnWidth, $defaultFont);
|
||||
|
||||
// Return
|
||||
return round($columnWidth, 6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get GD text width in pixels for a string of text in a certain font at a certain rotation angle
|
||||
*
|
||||
* @param string $text
|
||||
* @param PHPExcel_Style_Font
|
||||
* @param int $rotation
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0) {
|
||||
if (!function_exists('imagettfbbox')) {
|
||||
throw new Exception('GD library needs to be enabled');
|
||||
}
|
||||
|
||||
// font size should really be supplied in pixels in GD2,
|
||||
// but since GD2 seems to assume 72dpi, pixels and points are the same
|
||||
$fontFile = self::getTrueTypeFontFileFromFont($font);
|
||||
$textBox = imagettfbbox($font->getSize(), $rotation, $fontFile, $text);
|
||||
|
||||
// Get corners positions
|
||||
$lowerLeftCornerX = $textBox[0];
|
||||
$lowerLeftCornerY = $textBox[1];
|
||||
$lowerRightCornerX = $textBox[2];
|
||||
$lowerRightCornerY = $textBox[3];
|
||||
$upperRightCornerX = $textBox[4];
|
||||
$upperRightCornerY = $textBox[5];
|
||||
$upperLeftCornerX = $textBox[6];
|
||||
$upperLeftCornerY = $textBox[7];
|
||||
|
||||
// Calculate column width
|
||||
// values 1.025 and 0.584 found via interpolation by inspecting real Excel files with
|
||||
// Calibri font. May need further adjustment
|
||||
$columnWidth = 1.025 * strlen($columnText) + 0.584; // Excel adds some padding
|
||||
// Consider the rotation when calculating the width
|
||||
$textWidth = max($lowerRightCornerX - $upperLeftCornerX, $upperRightCornerX - $lowerLeftCornerX);
|
||||
|
||||
return $textWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get approximate width in pixels for a string of text in a certain font at a certain rotation angle
|
||||
*
|
||||
* @param string $columnText
|
||||
* @param PHPExcel_Style_Font $font
|
||||
* @param int $rotation
|
||||
* @return int Text width in pixels (no padding added)
|
||||
*/
|
||||
public static function getTextWidthPixelsApprox($columnText, PHPExcel_Style_Font $font = null, $rotation = 0)
|
||||
{
|
||||
$fontName = $font->getName();
|
||||
$fontSize = $font->getSize();
|
||||
|
||||
// Calculate column width in pixels. We assume fixed glyph width. Result varies with font name and size.
|
||||
switch ($fontName) {
|
||||
case 'Calibri':
|
||||
// value 8.26 was found via interpolation by inspecting real Excel files with Calibri 11 font.
|
||||
$columnWidth = (int) (8.26 * PHPExcel_Shared_String::CountCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
|
||||
break;
|
||||
|
||||
case 'Arial':
|
||||
// value 7 was found via interpolation by inspecting real Excel files with Arial 10 font.
|
||||
$columnWidth = (int) (7 * PHPExcel_Shared_String::CountCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
|
||||
break;
|
||||
|
||||
case 'Verdana':
|
||||
// value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font.
|
||||
$columnWidth = (int) (8 * PHPExcel_Shared_String::CountCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size
|
||||
break;
|
||||
|
||||
default:
|
||||
// just assume Calibri
|
||||
$columnWidth = (int) (8.26 * PHPExcel_Shared_String::CountCharacters($columnText));
|
||||
$columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size
|
||||
break;
|
||||
}
|
||||
|
||||
// Calculate approximate rotated column width
|
||||
if ($rotation !== 0) {
|
||||
@@ -101,18 +377,19 @@ class PHPExcel_Shared_Font
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
return round($columnWidth, 6);
|
||||
// pixel width is an integer
|
||||
$columnWidth = (int) $columnWidth;
|
||||
return $columnWidth;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate an (approximate) pixel size, based on a font points size
|
||||
*
|
||||
* @param int $fontSizeInPoints Font size (in points)
|
||||
* @return int Font size (in pixels)
|
||||
*/
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 12) {
|
||||
return ((16 / 12) * $fontSizeInPoints);
|
||||
public static function fontSizeToPixels($fontSizeInPoints = 11) {
|
||||
return (int) ((4 / 3) * $fontSizeInPoints);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,6 +412,133 @@ class PHPExcel_Shared_Font
|
||||
return ($sizeInCm * 37.795275591);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font path given the font
|
||||
*
|
||||
* @param PHPExcel_Style_Font
|
||||
* @return string Path to TrueType font file
|
||||
*/
|
||||
public static function getTrueTypeFontFileFromFont($font) {
|
||||
if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) {
|
||||
throw new Exception('Valid directory to TrueType Font files not specified');
|
||||
}
|
||||
|
||||
$name = $font->getName();
|
||||
$bold = $font->getBold();
|
||||
$italic = $font->getItalic();
|
||||
|
||||
// Check if we can map font to true type font file
|
||||
switch ($name) {
|
||||
case 'Arial':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::ARIAL_BOLD_ITALIC : self::ARIAL_BOLD)
|
||||
: ($italic ? self::ARIAL_ITALIC : self::ARIAL)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Calibri':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
|
||||
: ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Courier New':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
|
||||
: ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Comic Sans MS':
|
||||
$fontFile = (
|
||||
$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Georgia':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
|
||||
: ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Impact':
|
||||
$fontFile = self::IMPACT;
|
||||
break;
|
||||
|
||||
case 'Liberation Sans':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
|
||||
: ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Lucida Console':
|
||||
$fontFile = self::LUCIDA_CONSOLE;
|
||||
break;
|
||||
|
||||
case 'Lucida Sans Unicode':
|
||||
$fontFile = self::LUCIDA_SANS_UNICODE;
|
||||
break;
|
||||
|
||||
case 'Microsoft Sans Serif':
|
||||
$fontFile = self::MICROSOFT_SANS_SERIF;
|
||||
break;
|
||||
|
||||
case 'Palatino Linotype':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
|
||||
: ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Symbol':
|
||||
$fontFile = self::SYMBOL;
|
||||
break;
|
||||
|
||||
case 'Tahoma':
|
||||
$fontFile = (
|
||||
$bold ? self::TAHOMA_BOLD : self::TAHOMA
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Times New Roman':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
|
||||
: ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Trebuchet MS':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
|
||||
: ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Verdana':
|
||||
$fontFile = (
|
||||
$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
|
||||
: ($italic ? self::VERDANA_ITALIC : self::VERDANA)
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file');
|
||||
break;
|
||||
}
|
||||
|
||||
$fontFile = self::$trueTypeFontPath . $fontFile;
|
||||
|
||||
// Check if file actually exists
|
||||
if (!file_exists($fontFile)) {
|
||||
throw New Exception('TrueType Font file not found');
|
||||
}
|
||||
|
||||
return $fontFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the associated charset for the font name.
|
||||
*
|
||||
@@ -145,6 +549,7 @@ class PHPExcel_Shared_Font
|
||||
{
|
||||
switch ($name) {
|
||||
// Add more cases. Check FONT records in real Excel files.
|
||||
case 'EucrosiaUPC': return self::CHARSET_ANSI_THAI;
|
||||
case 'Wingdings': return self::CHARSET_SYMBOL;
|
||||
case 'Wingdings 2': return self::CHARSET_SYMBOL;
|
||||
case 'Wingdings 3': return self::CHARSET_SYMBOL;
|
||||
@@ -152,4 +557,214 @@ class PHPExcel_Shared_Font
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective column width for columns without a column dimension or column with width -1
|
||||
* For example, for Calibri 11 this is 9.140625 (64 px)
|
||||
*
|
||||
* @param PHPExcel_Style_Font $font The workbooks default font
|
||||
* @param boolean $pPixels true = return column width in pixels, false = return in OOXML units
|
||||
* @return mixed Column width
|
||||
*/
|
||||
public static function getDefaultColumnWidthByFont(PHPExcel_Style_Font $font, $pPixels = false)
|
||||
{
|
||||
if (isset(self::$defaultColumnWidths[$font->getName()][$font->getSize()])) {
|
||||
// Exact width can be determined
|
||||
$columnWidth = $pPixels ?
|
||||
self::$defaultColumnWidths[$font->getName()][$font->getSize()]['px']
|
||||
: self::$defaultColumnWidths[$font->getName()][$font->getSize()]['width'];
|
||||
|
||||
} else {
|
||||
// We don't have data for this particular font and size, use approximation by
|
||||
// extrapolating from Calibri 11
|
||||
$columnWidth = $pPixels ?
|
||||
self::$defaultColumnWidths['Calibri'][11]['px']
|
||||
: self::$defaultColumnWidths['Calibri'][11]['width'];
|
||||
$columnWidth = $columnWidth * $font->getSize() / 11;
|
||||
|
||||
// Round pixels to closest integer
|
||||
if ($pPixels) {
|
||||
$columnWidth = (int) round($columnWidth);
|
||||
}
|
||||
}
|
||||
|
||||
return $columnWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective row height for rows without a row dimension or rows with height -1
|
||||
* For example, for Calibri 11 this is 15 points
|
||||
*
|
||||
* @param PHPExcel_Style_Font $font The workbooks default font
|
||||
* @return float Row height in points
|
||||
*/
|
||||
public static function getDefaultRowHeightByFont(PHPExcel_Style_Font $font)
|
||||
{
|
||||
switch ($font->getName()) {
|
||||
case 'Arial':
|
||||
switch ($font->getSize()) {
|
||||
case 10:
|
||||
// inspection of Arial 10 workbook says 12.75pt ~17px
|
||||
$rowHeight = 12.75;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
// inspection of Arial 9 workbook says 12.00pt ~16px
|
||||
$rowHeight = 12;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
// inspection of Arial 8 workbook says 11.25pt ~15px
|
||||
$rowHeight = 11.25;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
// inspection of Arial 7 workbook says 9.00pt ~12px
|
||||
$rowHeight = 9;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case 5:
|
||||
// inspection of Arial 5,6 workbook says 8.25pt ~11px
|
||||
$rowHeight = 8.25;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// inspection of Arial 4 workbook says 6.75pt ~9px
|
||||
$rowHeight = 6.75;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// inspection of Arial 3 workbook says 6.00pt ~8px
|
||||
$rowHeight = 6;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 1:
|
||||
// inspection of Arial 1,2 workbook says 5.25pt ~7px
|
||||
$rowHeight = 5.25;
|
||||
break;
|
||||
|
||||
default:
|
||||
// use Arial 10 workbook as an approximation, extrapolation
|
||||
$rowHeight = 12.75 * $font->getSize() / 10;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Calibri':
|
||||
switch ($font->getSize()) {
|
||||
case 11:
|
||||
// inspection of Calibri 11 workbook says 15.00pt ~20px
|
||||
$rowHeight = 15;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
// inspection of Calibri 10 workbook says 12.75pt ~17px
|
||||
$rowHeight = 12.75;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
// inspection of Calibri 9 workbook says 12.00pt ~16px
|
||||
$rowHeight = 12;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
// inspection of Calibri 8 workbook says 11.25pt ~15px
|
||||
$rowHeight = 11.25;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
// inspection of Calibri 7 workbook says 9.00pt ~12px
|
||||
$rowHeight = 9;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case 5:
|
||||
// inspection of Calibri 5,6 workbook says 8.25pt ~11px
|
||||
$rowHeight = 8.25;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// inspection of Calibri 4 workbook says 6.75pt ~9px
|
||||
$rowHeight = 6.75;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// inspection of Calibri 3 workbook says 6.00pt ~8px
|
||||
$rowHeight = 6.00;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 1:
|
||||
// inspection of Calibri 1,2 workbook says 5.25pt ~7px
|
||||
$rowHeight = 5.25;
|
||||
break;
|
||||
|
||||
default:
|
||||
// use Calibri 11 workbook as an approximation, extrapolation
|
||||
$rowHeight = 15 * $font->getSize() / 11;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Verdana':
|
||||
switch ($font->getSize()) {
|
||||
case 10:
|
||||
// inspection of Verdana 10 workbook says 12.75pt ~17px
|
||||
$rowHeight = 12.75;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
// inspection of Verdana 9 workbook says 11.25pt ~15px
|
||||
$rowHeight = 11.25;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
// inspection of Verdana 8 workbook says 10.50pt ~14px
|
||||
$rowHeight = 10.50;
|
||||
break;
|
||||
|
||||
case 7:
|
||||
// inspection of Verdana 7 workbook says 9.00pt ~12px
|
||||
$rowHeight = 9.00;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case 5:
|
||||
// inspection of Verdana 5,6 workbook says 8.25pt ~11px
|
||||
$rowHeight = 8.25;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// inspection of Verdana 4 workbook says 6.75pt ~9px
|
||||
$rowHeight = 6.75;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// inspection of Verdana 3 workbook says 6.00pt ~8px
|
||||
$rowHeight = 6;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 1:
|
||||
// inspection of Verdana 1,2 workbook says 5.25pt ~7px
|
||||
$rowHeight = 5.25;
|
||||
break;
|
||||
|
||||
default:
|
||||
// use Verdana 10 workbook as an approximation, extrapolation
|
||||
$rowHeight = 12.75 * $font->getSize() / 10;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// just use Calibri as an approximation
|
||||
$rowHeight = 15 * $font->getSize() / 11;
|
||||
break;
|
||||
}
|
||||
|
||||
return $rowHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,6 +21,8 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/LUDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/QRDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/EigenvalueDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/SingularValueDecomposition.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/String.php';
|
||||
require_once PHPEXCEL_ROOT . 'PHPExcel/Calculation/Functions.php';
|
||||
|
||||
/*
|
||||
* Matrix class
|
||||
@@ -760,7 +762,21 @@ class Matrix {
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$this->A[$i][$j] += $M->get($i, $j);
|
||||
$validValues = True;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
|
||||
}
|
||||
if ((is_string($value)) && (!is_numeric($value))) {
|
||||
$value = trim($value,'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
|
||||
}
|
||||
if ($validValues) {
|
||||
$this->A[$i][$j] += $value;
|
||||
} else {
|
||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
@@ -832,7 +848,21 @@ class Matrix {
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$this->A[$i][$j] -= $M->get($i, $j);
|
||||
$validValues = True;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
|
||||
}
|
||||
if ((is_string($value)) && (!is_numeric($value))) {
|
||||
$value = trim($value,'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
|
||||
}
|
||||
if ($validValues) {
|
||||
$this->A[$i][$j] -= $value;
|
||||
} else {
|
||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
@@ -906,7 +936,21 @@ class Matrix {
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$this->A[$i][$j] *= $M->get($i, $j);
|
||||
$validValues = True;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
|
||||
}
|
||||
if ((is_string($value)) && (!is_numeric($value))) {
|
||||
$value = trim($value,'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
|
||||
}
|
||||
if ($validValues) {
|
||||
$this->A[$i][$j] *= $value;
|
||||
} else {
|
||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
@@ -943,7 +987,26 @@ class Matrix {
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$M->set($i, $j, $this->A[$i][$j] / $M->get($i, $j));
|
||||
$validValues = True;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
|
||||
}
|
||||
if ((is_string($value)) && (!is_numeric($value))) {
|
||||
$value = trim($value,'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
|
||||
}
|
||||
if ($validValues) {
|
||||
if ($value == 0) {
|
||||
// Trap for Divide by Zero error
|
||||
$M->set($i, $j, '#DIV/0!');
|
||||
} else {
|
||||
$M->set($i, $j, $this->A[$i][$j] / $value);
|
||||
}
|
||||
} else {
|
||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $M;
|
||||
@@ -1181,7 +1244,21 @@ class Matrix {
|
||||
$this->checkMatrixDimensions($M);
|
||||
for($i = 0; $i < $this->m; ++$i) {
|
||||
for($j = 0; $j < $this->n; ++$j) {
|
||||
$this->A[$i][$j] = pow($this->A[$i][$j],$M->get($i, $j));
|
||||
$validValues = True;
|
||||
$value = $M->get($i, $j);
|
||||
if ((is_string($this->A[$i][$j])) && (!is_numeric($this->A[$i][$j]))) {
|
||||
$this->A[$i][$j] = trim($this->A[$i][$j],'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
|
||||
}
|
||||
if ((is_string($value)) && (!is_numeric($value))) {
|
||||
$value = trim($value,'"');
|
||||
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
|
||||
}
|
||||
if ($validValues) {
|
||||
$this->A[$i][$j] = pow($this->A[$i][$j],$value);
|
||||
} else {
|
||||
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (C) 2006 - 2009 PHPExcel
|
||||
* Copyright (C) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -22,7 +22,7 @@
|
||||
* @package PHPExcel_Shared_OLE
|
||||
* @copyright Copyright (c) 2006 - 2007 Christian Schmidt
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
/** PHPExcel root directory */
|
||||
|
@@ -248,7 +248,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
|
||||
. pack("V", 0)
|
||||
. pack("V", 0x1000)
|
||||
. pack("V", $iSBDcnt ? 0 : -2) //Small Block Depot
|
||||
. pack("V", 1)
|
||||
. pack("V", $iSBDcnt)
|
||||
);
|
||||
// Extra BDList Start, Count
|
||||
if ($iBdCnt < $i1stBdL) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1));
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_PasswordHasher
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,10 +31,16 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_String
|
||||
{
|
||||
/** Constants */
|
||||
/** Regular Expressions */
|
||||
// Fraction
|
||||
const STRING_REGEXP_FRACTION = '(-?)(\d+)\s+(\d+\/\d+)';
|
||||
|
||||
|
||||
/**
|
||||
* Control characters array
|
||||
*
|
||||
@@ -42,6 +48,20 @@ class PHPExcel_Shared_String
|
||||
*/
|
||||
private static $_controlCharacters = array();
|
||||
|
||||
/**
|
||||
* Decimal separator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_decimalSeparator;
|
||||
|
||||
/**
|
||||
* Thousands separator
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private static $_thousandsSeparator;
|
||||
|
||||
/**
|
||||
* Is mbstring extension avalable?
|
||||
*
|
||||
@@ -60,7 +80,7 @@ class PHPExcel_Shared_String
|
||||
* Build control characters array
|
||||
*/
|
||||
private static function _buildControlCharacters() {
|
||||
for ($i = 0; $i <= 19; ++$i) {
|
||||
for ($i = 0; $i <= 31; ++$i) {
|
||||
if ($i != 9 && $i != 10 && $i != 13) {
|
||||
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
|
||||
$replace = chr($i);
|
||||
@@ -97,12 +117,19 @@ class PHPExcel_Shared_String
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
|
||||
// IBM AIX iconv() does not work
|
||||
self::$_isIconvEnabled = function_exists('iconv') &&
|
||||
!(defined('PHP_OS') && @stristr(PHP_OS, 'AIX') && defined('ICONV_IMPL')
|
||||
&& (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && defined('ICONV_VERSION')
|
||||
&& (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) ?
|
||||
true : false;
|
||||
// Check that iconv exists
|
||||
// Sometimes iconv is not working, and e.g. iconv('UTF-8', 'UTF-16LE', 'x') just returns false,
|
||||
// we cannot use iconv when that happens
|
||||
// Also, sometimes iconv_substr('A', 0, 1, 'UTF-8') just returns false in PHP 5.2.0
|
||||
// we cannot use iconv in that case either (http://bugs.php.net/bug.php?id=37773)
|
||||
if (function_exists('iconv')
|
||||
&& @iconv('UTF-8', 'UTF-16LE', 'x')
|
||||
&& @iconv_substr('A', 0, 1, 'UTF-8') ) {
|
||||
|
||||
self::$_isIconvEnabled = true;
|
||||
} else {
|
||||
self::$_isIconvEnabled = false;
|
||||
}
|
||||
|
||||
return self::$_isIconvEnabled;
|
||||
}
|
||||
@@ -172,7 +199,7 @@ class PHPExcel_Shared_String
|
||||
// else, no conversion
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a string contains UTF8 data
|
||||
*
|
||||
@@ -213,7 +240,7 @@ class PHPExcel_Shared_String
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
|
||||
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
|
||||
// characters
|
||||
@@ -239,7 +266,7 @@ class PHPExcel_Shared_String
|
||||
$ln = self::CountCharacters($value, 'UTF-8');
|
||||
|
||||
// option flags
|
||||
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
|
||||
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
|
||||
0x0001 : 0x0000;
|
||||
|
||||
// characters
|
||||
@@ -272,7 +299,7 @@ class PHPExcel_Shared_String
|
||||
// else, no conversion
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get character count. First try mbstring, then iconv, finally strlen
|
||||
*
|
||||
@@ -322,4 +349,82 @@ class PHPExcel_Shared_String
|
||||
return $string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Identify whether a string contains a fractional numeric value,
|
||||
* and convert it to a numeric if it is
|
||||
*
|
||||
* @param string &$operand string value to test
|
||||
* @return boolean
|
||||
*/
|
||||
public static function convertToNumberIfFraction(&$operand) {
|
||||
if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) {
|
||||
$sign = ($match[1] == '-') ? '-' : '+';
|
||||
$fractionFormula = '='.$sign.$match[2].$sign.$match[3];
|
||||
$operand = PHPExcel_Calculation::getInstance()->_calculateFormulaValue($fractionFormula);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} // function convertToNumberIfFraction()
|
||||
|
||||
/**
|
||||
* Get the decimal separator. If it has not yet been set explicitly, try to obtain number
|
||||
* formatting information from locale.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDecimalSeparator()
|
||||
{
|
||||
if (!isset(self::$_decimalSeparator)) {
|
||||
$localeconv = localeconv();
|
||||
self::$_decimalSeparator = $localeconv['decimal_point'] != ''
|
||||
? $localeconv['decimal_point'] : $localeconv['mon_decimal_point'];
|
||||
|
||||
if (self::$_decimalSeparator == '')
|
||||
{
|
||||
// Default to .
|
||||
self::$_decimalSeparator = '.';
|
||||
}
|
||||
}
|
||||
return self::$_decimalSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the decimal separator. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
|
||||
* to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
|
||||
*
|
||||
* @param string $pValue Character for decimal separator
|
||||
*/
|
||||
public static function setDecimalSeparator($pValue = '.')
|
||||
{
|
||||
self::$_decimalSeparator = $pValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the thousands separator. If it has not yet been set explicitly, try to obtain number
|
||||
* formatting information from locale.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getThousandsSeparator()
|
||||
{
|
||||
if (!isset(self::$_thousandsSeparator)) {
|
||||
$localeconv = localeconv();
|
||||
self::$_thousandsSeparator = $localeconv['thousands_sep'] != ''
|
||||
? $localeconv['thousands_sep'] : $localeconv['mon_thousands_sep'];
|
||||
}
|
||||
return self::$_thousandsSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the thousands separator. Only used by PHPExcel_Style_NumberFormat::toFormattedString()
|
||||
* to format output by PHPExcel_Writer_HTML and PHPExcel_Writer_PDF
|
||||
*
|
||||
* @param string $pValue Character for thousands separator
|
||||
*/
|
||||
public static function setThousandsSeparator($pValue = ',')
|
||||
{
|
||||
self::$_thousandsSeparator = $pValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
if (!defined('DATE_W3C')) {
|
||||
@@ -34,7 +34,7 @@ if (!defined('DATE_W3C')) {
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_XMLWriter {
|
||||
/** Temporary storage method */
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ PHPExcel_Shared_ZipStreamWrapper::register();
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Shared_ZipStreamWrapper {
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ class PHPExcel_Shared_ZipStreamWrapper {
|
||||
}
|
||||
|
||||
// Parse URL
|
||||
$url = @parse_url($path);
|
||||
$url = @parse_url(str_replace('zip://', 'file://', $path));
|
||||
|
||||
// Fix URL
|
||||
if (!is_array($url)) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Best_Fit
|
||||
{
|
||||
@@ -239,7 +239,11 @@ class PHPExcel_Best_Fit
|
||||
$this->_SSResiduals = $SSres;
|
||||
$this->_DFResiduals = $this->_valueCount - 1 - $const;
|
||||
|
||||
$this->_stdevOfResiduals = sqrt($SSres / $this->_DFResiduals);
|
||||
if ($this->_DFResiduals == 0.0) {
|
||||
$this->_stdevOfResiduals = 0.0;
|
||||
} else {
|
||||
$this->_stdevOfResiduals = sqrt($SSres / $this->_DFResiduals);
|
||||
}
|
||||
if (($SStot == 0.0) || ($SSres == $SStot)) {
|
||||
$this->_goodnessOfFit = 1;
|
||||
} else {
|
||||
@@ -252,9 +256,17 @@ class PHPExcel_Best_Fit
|
||||
$this->_slopeSE = $this->_stdevOfResiduals / sqrt($SSsex);
|
||||
$this->_intersectSE = $this->_stdevOfResiduals * sqrt(1 / ($this->_valueCount - ($sumX * $sumX) / $sumX2));
|
||||
if ($this->_SSResiduals != 0.0) {
|
||||
$this->_F = $this->_SSRegression / ($this->_SSResiduals / $this->_DFResiduals);
|
||||
if ($this->_DFResiduals == 0.0) {
|
||||
$this->_F = 0.0;
|
||||
} else {
|
||||
$this->_F = $this->_SSRegression / ($this->_SSResiduals / $this->_DFResiduals);
|
||||
}
|
||||
} else {
|
||||
$this->_F = $this->_SSRegression / $this->_DFResiduals;
|
||||
if ($this->_DFResiduals == 0.0) {
|
||||
$this->_F = 0.0;
|
||||
} else {
|
||||
$this->_F = $this->_SSRegression / $this->_DFResiduals;
|
||||
}
|
||||
}
|
||||
} // function _calculateGoodnessOfFit()
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||
{
|
||||
@@ -84,8 +84,14 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
||||
|
||||
|
||||
private function _exponential_regression($yValues, $xValues, $const) {
|
||||
$mArray = $xValues;
|
||||
$yValues = array_map('log',$yValues);
|
||||
foreach($yValues as &$value) {
|
||||
if ($value < 0.0) {
|
||||
$value = 0 - log(abs($value));
|
||||
} elseif ($value > 0.0) {
|
||||
$value = log($value);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
||||
} // function _exponential_regression()
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||
{
|
||||
@@ -68,8 +68,14 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
||||
|
||||
|
||||
private function _logarithmic_regression($yValues, $xValues, $const) {
|
||||
$mArray = $xValues;
|
||||
$xValues = array_map('log',$xValues);
|
||||
foreach($xValues as &$value) {
|
||||
if ($value < 0.0) {
|
||||
$value = 0 - log(abs($value));
|
||||
} elseif ($value > 0.0) {
|
||||
$value = log($value);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
||||
} // function _logarithmic_regression()
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2009 PHPExcel
|
||||
* Copyright (c) 2006 - 2010 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,9 +20,9 @@
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.7.0, 2009-08-10
|
||||
* @version 1.7.2, 2010-01-11
|
||||
*/
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php';
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Shared_Best_Fit
|
||||
* @copyright Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||
{
|
||||
@@ -76,10 +76,22 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
||||
|
||||
|
||||
private function _power_regression($yValues, $xValues, $const) {
|
||||
$mArray = $xValues;
|
||||
sort($mArray,SORT_NUMERIC);
|
||||
$xValues = array_map('log',$xValues);
|
||||
$yValues = array_map('log',$yValues);
|
||||
foreach($xValues as &$value) {
|
||||
if ($value < 0.0) {
|
||||
$value = 0 - log(abs($value));
|
||||
} elseif ($value > 0.0) {
|
||||
$value = log($value);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
foreach($yValues as &$value) {
|
||||
if ($value < 0.0) {
|
||||
$value = 0 - log(abs($value));
|
||||
} elseif ($value > 0.0) {
|
||||
$value = log($value);
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
|
||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
||||
} // function _power_regression()
|
||||
|
Reference in New Issue
Block a user