mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-25 23:06:03 +03:00
More efforts to get codebase to conform with PSR-2 coding standards
This commit is contained in:
parent
547d2bd3b2
commit
c70e289dac
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Comment
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -24,15 +25,6 @@
|
|||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Comment
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Comment implements PHPExcel_IComparable
|
class PHPExcel_Comment implements PHPExcel_IComparable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -106,10 +98,10 @@ class PHPExcel_Comment implements PHPExcel_IComparable
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Initialise variables
|
// Initialise variables
|
||||||
$this->_author = 'Author';
|
$this->_author = 'Author';
|
||||||
$this->_text = new PHPExcel_RichText();
|
$this->_text = new PHPExcel_RichText();
|
||||||
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
$this->_fillColor = new PHPExcel_Style_Color('FFFFFFE1');
|
||||||
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
$this->_alignment = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_DocumentProperties
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -24,19 +25,10 @@
|
|||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_DocumentProperties
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_DocumentProperties
|
class PHPExcel_DocumentProperties
|
||||||
{
|
{
|
||||||
/** constants */
|
/** constants */
|
||||||
const PROPERTY_TYPE_BOOLEAN = 'b';
|
const PROPERTY_TYPE_BOOLEAN = 'b';
|
||||||
const PROPERTY_TYPE_INTEGER = 'i';
|
const PROPERTY_TYPE_INTEGER = 'i';
|
||||||
const PROPERTY_TYPE_FLOAT = 'f';
|
const PROPERTY_TYPE_FLOAT = 'f';
|
||||||
const PROPERTY_TYPE_DATE = 'd';
|
const PROPERTY_TYPE_DATE = 'd';
|
||||||
@ -48,7 +40,7 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_creator = 'Unknown Creator';
|
private $_creator = 'Unknown Creator';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LastModifiedBy
|
* LastModifiedBy
|
||||||
@ -76,56 +68,56 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_title = 'Untitled Spreadsheet';
|
private $_title = 'Untitled Spreadsheet';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description
|
* Description
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_description = '';
|
private $_description = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subject
|
* Subject
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_subject = '';
|
private $_subject = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keywords
|
* Keywords
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_keywords = '';
|
private $_keywords = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category
|
* Category
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_category = '';
|
private $_category = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manager
|
* Manager
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_manager = '';
|
private $_manager = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Company
|
* Company
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_company = 'Microsoft Corporation';
|
private $_company = 'Microsoft Corporation';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom Properties
|
* Custom Properties
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_customProperties = array();
|
private $_customProperties = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,7 +136,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCreator() {
|
public function getCreator()
|
||||||
|
{
|
||||||
return $this->_creator;
|
return $this->_creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +147,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setCreator($pValue = '') {
|
public function setCreator($pValue = '')
|
||||||
|
{
|
||||||
$this->_creator = $pValue;
|
$this->_creator = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -164,7 +158,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLastModifiedBy() {
|
public function getLastModifiedBy()
|
||||||
|
{
|
||||||
return $this->_lastModifiedBy;
|
return $this->_lastModifiedBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +169,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setLastModifiedBy($pValue = '') {
|
public function setLastModifiedBy($pValue = '')
|
||||||
|
{
|
||||||
$this->_lastModifiedBy = $pValue;
|
$this->_lastModifiedBy = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -184,7 +180,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return datetime
|
* @return datetime
|
||||||
*/
|
*/
|
||||||
public function getCreated() {
|
public function getCreated()
|
||||||
|
{
|
||||||
return $this->_created;
|
return $this->_created;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +191,9 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param datetime $pValue
|
* @param datetime $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setCreated($pValue = null) {
|
public function setCreated($pValue = null)
|
||||||
if ($pValue === NULL) {
|
{
|
||||||
|
if ($pValue === null) {
|
||||||
$pValue = time();
|
$pValue = time();
|
||||||
} elseif (is_string($pValue)) {
|
} elseif (is_string($pValue)) {
|
||||||
if (is_numeric($pValue)) {
|
if (is_numeric($pValue)) {
|
||||||
@ -214,7 +212,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return datetime
|
* @return datetime
|
||||||
*/
|
*/
|
||||||
public function getModified() {
|
public function getModified()
|
||||||
|
{
|
||||||
return $this->_modified;
|
return $this->_modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,8 +223,9 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param datetime $pValue
|
* @param datetime $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setModified($pValue = null) {
|
public function setModified($pValue = null)
|
||||||
if ($pValue === NULL) {
|
{
|
||||||
|
if ($pValue === null) {
|
||||||
$pValue = time();
|
$pValue = time();
|
||||||
} elseif (is_string($pValue)) {
|
} elseif (is_string($pValue)) {
|
||||||
if (is_numeric($pValue)) {
|
if (is_numeric($pValue)) {
|
||||||
@ -244,7 +244,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getTitle() {
|
public function getTitle()
|
||||||
|
{
|
||||||
return $this->_title;
|
return $this->_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +255,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setTitle($pValue = '') {
|
public function setTitle($pValue = '')
|
||||||
|
{
|
||||||
$this->_title = $pValue;
|
$this->_title = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -264,7 +266,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
return $this->_description;
|
return $this->_description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +277,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setDescription($pValue = '') {
|
public function setDescription($pValue = '')
|
||||||
|
{
|
||||||
$this->_description = $pValue;
|
$this->_description = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -284,7 +288,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSubject() {
|
public function getSubject()
|
||||||
|
{
|
||||||
return $this->_subject;
|
return $this->_subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +299,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setSubject($pValue = '') {
|
public function setSubject($pValue = '')
|
||||||
|
{
|
||||||
$this->_subject = $pValue;
|
$this->_subject = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -304,7 +310,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getKeywords() {
|
public function getKeywords()
|
||||||
|
{
|
||||||
return $this->_keywords;
|
return $this->_keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +321,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setKeywords($pValue = '') {
|
public function setKeywords($pValue = '')
|
||||||
|
{
|
||||||
$this->_keywords = $pValue;
|
$this->_keywords = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -324,7 +332,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCategory() {
|
public function getCategory()
|
||||||
|
{
|
||||||
return $this->_category;
|
return $this->_category;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +343,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setCategory($pValue = '') {
|
public function setCategory($pValue = '')
|
||||||
|
{
|
||||||
$this->_category = $pValue;
|
$this->_category = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -344,7 +354,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCompany() {
|
public function getCompany()
|
||||||
|
{
|
||||||
return $this->_company;
|
return $this->_company;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +365,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setCompany($pValue = '') {
|
public function setCompany($pValue = '')
|
||||||
|
{
|
||||||
$this->_company = $pValue;
|
$this->_company = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -364,7 +376,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getManager() {
|
public function getManager()
|
||||||
|
{
|
||||||
return $this->_manager;
|
return $this->_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,7 +387,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setManager($pValue = '') {
|
public function setManager($pValue = '')
|
||||||
|
{
|
||||||
$this->_manager = $pValue;
|
$this->_manager = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -384,7 +398,8 @@ class PHPExcel_DocumentProperties
|
|||||||
*
|
*
|
||||||
* @return array of string
|
* @return array of string
|
||||||
*/
|
*/
|
||||||
public function getCustomProperties() {
|
public function getCustomProperties()
|
||||||
|
{
|
||||||
return array_keys($this->_customProperties);
|
return array_keys($this->_customProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,7 +409,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $propertyName
|
* @param string $propertyName
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isCustomPropertySet($propertyName) {
|
public function isCustomPropertySet($propertyName)
|
||||||
|
{
|
||||||
return isset($this->_customProperties[$propertyName]);
|
return isset($this->_customProperties[$propertyName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +420,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $propertyName
|
* @param string $propertyName
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCustomPropertyValue($propertyName) {
|
public function getCustomPropertyValue($propertyName)
|
||||||
|
{
|
||||||
if (isset($this->_customProperties[$propertyName])) {
|
if (isset($this->_customProperties[$propertyName])) {
|
||||||
return $this->_customProperties[$propertyName]['value'];
|
return $this->_customProperties[$propertyName]['value'];
|
||||||
}
|
}
|
||||||
@ -417,7 +434,8 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $propertyName
|
* @param string $propertyName
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCustomPropertyType($propertyName) {
|
public function getCustomPropertyType($propertyName)
|
||||||
|
{
|
||||||
if (isset($this->_customProperties[$propertyName])) {
|
if (isset($this->_customProperties[$propertyName])) {
|
||||||
return $this->_customProperties[$propertyName]['type'];
|
return $this->_customProperties[$propertyName]['type'];
|
||||||
}
|
}
|
||||||
@ -430,20 +448,21 @@ class PHPExcel_DocumentProperties
|
|||||||
* @param string $propertyName
|
* @param string $propertyName
|
||||||
* @param mixed $propertyValue
|
* @param mixed $propertyValue
|
||||||
* @param string $propertyType
|
* @param string $propertyType
|
||||||
* 'i' : Integer
|
* 'i' : Integer
|
||||||
* 'f' : Floating Point
|
* 'f' : Floating Point
|
||||||
* 's' : String
|
* 's' : String
|
||||||
* 'd' : Date/Time
|
* 'd' : Date/Time
|
||||||
* 'b' : Boolean
|
* 'b' : Boolean
|
||||||
* @return PHPExcel_DocumentProperties
|
* @return PHPExcel_DocumentProperties
|
||||||
*/
|
*/
|
||||||
public function setCustomProperty($propertyName,$propertyValue='',$propertyType=NULL) {
|
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null)
|
||||||
if (($propertyType === NULL) || (!in_array($propertyType,array(self::PROPERTY_TYPE_INTEGER,
|
{
|
||||||
self::PROPERTY_TYPE_FLOAT,
|
if (($propertyType === null) || (!in_array($propertyType, array(self::PROPERTY_TYPE_INTEGER,
|
||||||
self::PROPERTY_TYPE_STRING,
|
self::PROPERTY_TYPE_FLOAT,
|
||||||
self::PROPERTY_TYPE_DATE,
|
self::PROPERTY_TYPE_STRING,
|
||||||
self::PROPERTY_TYPE_BOOLEAN)))) {
|
self::PROPERTY_TYPE_DATE,
|
||||||
if ($propertyValue === NULL) {
|
self::PROPERTY_TYPE_BOOLEAN)))) {
|
||||||
|
if ($propertyValue === null) {
|
||||||
$propertyType = self::PROPERTY_TYPE_STRING;
|
$propertyType = self::PROPERTY_TYPE_STRING;
|
||||||
} elseif (is_float($propertyValue)) {
|
} elseif (is_float($propertyValue)) {
|
||||||
$propertyType = self::PROPERTY_TYPE_FLOAT;
|
$propertyType = self::PROPERTY_TYPE_FLOAT;
|
||||||
@ -456,14 +475,18 @@ class PHPExcel_DocumentProperties
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_customProperties[$propertyName] = array('value' => $propertyValue, 'type' => $propertyType);
|
$this->_customProperties[$propertyName] = array(
|
||||||
|
'value' => $propertyValue,
|
||||||
|
'type' => $propertyType
|
||||||
|
);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
|
{
|
||||||
$vars = get_object_vars($this);
|
$vars = get_object_vars($this);
|
||||||
foreach ($vars as $key => $value) {
|
foreach ($vars as $key => $value) {
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
@ -474,58 +497,59 @@ class PHPExcel_DocumentProperties
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function convertProperty($propertyValue,$propertyType) {
|
public static function convertProperty($propertyValue,$propertyType)
|
||||||
|
{
|
||||||
switch ($propertyType) {
|
switch ($propertyType) {
|
||||||
case 'empty' : // Empty
|
case 'empty': // Empty
|
||||||
return '';
|
return '';
|
||||||
break;
|
break;
|
||||||
case 'null' : // Null
|
case 'null': // Null
|
||||||
return NULL;
|
return null;
|
||||||
break;
|
break;
|
||||||
case 'i1' : // 1-Byte Signed Integer
|
case 'i1': // 1-Byte Signed Integer
|
||||||
case 'i2' : // 2-Byte Signed Integer
|
case 'i2': // 2-Byte Signed Integer
|
||||||
case 'i4' : // 4-Byte Signed Integer
|
case 'i4': // 4-Byte Signed Integer
|
||||||
case 'i8' : // 8-Byte Signed Integer
|
case 'i8': // 8-Byte Signed Integer
|
||||||
case 'int' : // Integer
|
case 'int': // Integer
|
||||||
return (int) $propertyValue;
|
return (int) $propertyValue;
|
||||||
break;
|
break;
|
||||||
case 'ui1' : // 1-Byte Unsigned Integer
|
case 'ui1': // 1-Byte Unsigned Integer
|
||||||
case 'ui2' : // 2-Byte Unsigned Integer
|
case 'ui2': // 2-Byte Unsigned Integer
|
||||||
case 'ui4' : // 4-Byte Unsigned Integer
|
case 'ui4': // 4-Byte Unsigned Integer
|
||||||
case 'ui8' : // 8-Byte Unsigned Integer
|
case 'ui8': // 8-Byte Unsigned Integer
|
||||||
case 'uint' : // Unsigned Integer
|
case 'uint': // Unsigned Integer
|
||||||
return abs((int) $propertyValue);
|
return abs((int) $propertyValue);
|
||||||
break;
|
break;
|
||||||
case 'r4' : // 4-Byte Real Number
|
case 'r4': // 4-Byte Real Number
|
||||||
case 'r8' : // 8-Byte Real Number
|
case 'r8': // 8-Byte Real Number
|
||||||
case 'decimal' : // Decimal
|
case 'decimal': // Decimal
|
||||||
return (float) $propertyValue;
|
return (float) $propertyValue;
|
||||||
break;
|
break;
|
||||||
case 'lpstr' : // LPSTR
|
case 'lpstr': // LPSTR
|
||||||
case 'lpwstr' : // LPWSTR
|
case 'lpwstr': // LPWSTR
|
||||||
case 'bstr' : // Basic String
|
case 'bstr': // Basic String
|
||||||
return $propertyValue;
|
return $propertyValue;
|
||||||
break;
|
break;
|
||||||
case 'date' : // Date and Time
|
case 'date': // Date and Time
|
||||||
case 'filetime' : // File Time
|
case 'filetime': // File Time
|
||||||
return strtotime($propertyValue);
|
return strtotime($propertyValue);
|
||||||
break;
|
break;
|
||||||
case 'bool' : // Boolean
|
case 'bool': // Boolean
|
||||||
return ($propertyValue == 'true') ? True : False;
|
return ($propertyValue == 'true') ? True : False;
|
||||||
break;
|
break;
|
||||||
case 'cy' : // Currency
|
case 'cy': // Currency
|
||||||
case 'error' : // Error Status Code
|
case 'error': // Error Status Code
|
||||||
case 'vector' : // Vector
|
case 'vector': // Vector
|
||||||
case 'array' : // Array
|
case 'array': // Array
|
||||||
case 'blob' : // Binary Blob
|
case 'blob': // Binary Blob
|
||||||
case 'oblob' : // Binary Blob Object
|
case 'oblob': // Binary Blob Object
|
||||||
case 'stream' : // Binary Stream
|
case 'stream': // Binary Stream
|
||||||
case 'ostream' : // Binary Stream Object
|
case 'ostream': // Binary Stream Object
|
||||||
case 'storage' : // Binary Storage
|
case 'storage': // Binary Storage
|
||||||
case 'ostorage' : // Binary Storage Object
|
case 'ostorage': // Binary Storage Object
|
||||||
case 'vstream' : // Binary Versioned Stream
|
case 'vstream': // Binary Versioned Stream
|
||||||
case 'clsid' : // Class ID
|
case 'clsid': // Class ID
|
||||||
case 'cf' : // Clipboard Data
|
case 'cf': // Clipboard Data
|
||||||
return $propertyValue;
|
return $propertyValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -534,50 +558,50 @@ class PHPExcel_DocumentProperties
|
|||||||
|
|
||||||
public static function convertPropertyType($propertyType) {
|
public static function convertPropertyType($propertyType) {
|
||||||
switch ($propertyType) {
|
switch ($propertyType) {
|
||||||
case 'i1' : // 1-Byte Signed Integer
|
case 'i1': // 1-Byte Signed Integer
|
||||||
case 'i2' : // 2-Byte Signed Integer
|
case 'i2': // 2-Byte Signed Integer
|
||||||
case 'i4' : // 4-Byte Signed Integer
|
case 'i4': // 4-Byte Signed Integer
|
||||||
case 'i8' : // 8-Byte Signed Integer
|
case 'i8': // 8-Byte Signed Integer
|
||||||
case 'int' : // Integer
|
case 'int': // Integer
|
||||||
case 'ui1' : // 1-Byte Unsigned Integer
|
case 'ui1': // 1-Byte Unsigned Integer
|
||||||
case 'ui2' : // 2-Byte Unsigned Integer
|
case 'ui2': // 2-Byte Unsigned Integer
|
||||||
case 'ui4' : // 4-Byte Unsigned Integer
|
case 'ui4': // 4-Byte Unsigned Integer
|
||||||
case 'ui8' : // 8-Byte Unsigned Integer
|
case 'ui8': // 8-Byte Unsigned Integer
|
||||||
case 'uint' : // Unsigned Integer
|
case 'uint': // Unsigned Integer
|
||||||
return self::PROPERTY_TYPE_INTEGER;
|
return self::PROPERTY_TYPE_INTEGER;
|
||||||
break;
|
break;
|
||||||
case 'r4' : // 4-Byte Real Number
|
case 'r4': // 4-Byte Real Number
|
||||||
case 'r8' : // 8-Byte Real Number
|
case 'r8': // 8-Byte Real Number
|
||||||
case 'decimal' : // Decimal
|
case 'decimal': // Decimal
|
||||||
return self::PROPERTY_TYPE_FLOAT;
|
return self::PROPERTY_TYPE_FLOAT;
|
||||||
break;
|
break;
|
||||||
case 'empty' : // Empty
|
case 'empty': // Empty
|
||||||
case 'null' : // Null
|
case 'null': // Null
|
||||||
case 'lpstr' : // LPSTR
|
case 'lpstr': // LPSTR
|
||||||
case 'lpwstr' : // LPWSTR
|
case 'lpwstr': // LPWSTR
|
||||||
case 'bstr' : // Basic String
|
case 'bstr': // Basic String
|
||||||
return self::PROPERTY_TYPE_STRING;
|
return self::PROPERTY_TYPE_STRING;
|
||||||
break;
|
break;
|
||||||
case 'date' : // Date and Time
|
case 'date': // Date and Time
|
||||||
case 'filetime' : // File Time
|
case 'filetime': // File Time
|
||||||
return self::PROPERTY_TYPE_DATE;
|
return self::PROPERTY_TYPE_DATE;
|
||||||
break;
|
break;
|
||||||
case 'bool' : // Boolean
|
case 'bool': // Boolean
|
||||||
return self::PROPERTY_TYPE_BOOLEAN;
|
return self::PROPERTY_TYPE_BOOLEAN;
|
||||||
break;
|
break;
|
||||||
case 'cy' : // Currency
|
case 'cy': // Currency
|
||||||
case 'error' : // Error Status Code
|
case 'error': // Error Status Code
|
||||||
case 'vector' : // Vector
|
case 'vector': // Vector
|
||||||
case 'array' : // Array
|
case 'array': // Array
|
||||||
case 'blob' : // Binary Blob
|
case 'blob': // Binary Blob
|
||||||
case 'oblob' : // Binary Blob Object
|
case 'oblob': // Binary Blob Object
|
||||||
case 'stream' : // Binary Stream
|
case 'stream': // Binary Stream
|
||||||
case 'ostream' : // Binary Stream Object
|
case 'ostream': // Binary Stream Object
|
||||||
case 'storage' : // Binary Storage
|
case 'storage': // Binary Storage
|
||||||
case 'ostorage' : // Binary Storage Object
|
case 'ostorage': // Binary Storage Object
|
||||||
case 'vstream' : // Binary Versioned Stream
|
case 'vstream': // Binary Versioned Stream
|
||||||
case 'clsid' : // Class ID
|
case 'clsid': // Class ID
|
||||||
case 'cf' : // Clipboard Data
|
case 'cf': // Clipboard Data
|
||||||
return self::PROPERTY_TYPE_UNKNOWN;
|
return self::PROPERTY_TYPE_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_DocumentSecurity
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,66 +22,57 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_DocumentSecurity
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_DocumentSecurity
|
class PHPExcel_DocumentSecurity
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* LockRevision
|
* LockRevision
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_lockRevision;
|
private $_lockRevision;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LockStructure
|
* LockStructure
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_lockStructure;
|
private $_lockStructure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LockWindows
|
* LockWindows
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_lockWindows;
|
private $_lockWindows;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RevisionsPassword
|
* RevisionsPassword
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_revisionsPassword;
|
private $_revisionsPassword;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WorkbookPassword
|
* WorkbookPassword
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_workbookPassword;
|
private $_workbookPassword;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_DocumentSecurity
|
* Create a new PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Initialise values
|
// Initialise values
|
||||||
$this->_lockRevision = false;
|
$this->_lockRevision = false;
|
||||||
$this->_lockStructure = false;
|
$this->_lockStructure = false;
|
||||||
$this->_lockWindows = false;
|
$this->_lockWindows = false;
|
||||||
$this->_revisionsPassword = '';
|
$this->_revisionsPassword = '';
|
||||||
$this->_workbookPassword = '';
|
$this->_workbookPassword = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,10 +80,11 @@ class PHPExcel_DocumentSecurity
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function isSecurityEnabled() {
|
function isSecurityEnabled()
|
||||||
return $this->_lockRevision ||
|
{
|
||||||
$this->_lockStructure ||
|
return $this->_lockRevision ||
|
||||||
$this->_lockWindows;
|
$this->_lockStructure ||
|
||||||
|
$this->_lockWindows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,8 +92,9 @@ class PHPExcel_DocumentSecurity
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function getLockRevision() {
|
function getLockRevision()
|
||||||
return $this->_lockRevision;
|
{
|
||||||
|
return $this->_lockRevision;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,9 +103,10 @@ class PHPExcel_DocumentSecurity
|
|||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
* @return PHPExcel_DocumentSecurity
|
* @return PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
function setLockRevision($pValue = false) {
|
function setLockRevision($pValue = false)
|
||||||
$this->_lockRevision = $pValue;
|
{
|
||||||
return $this;
|
$this->_lockRevision = $pValue;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,8 +114,9 @@ class PHPExcel_DocumentSecurity
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function getLockStructure() {
|
function getLockStructure()
|
||||||
return $this->_lockStructure;
|
{
|
||||||
|
return $this->_lockStructure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,9 +125,10 @@ class PHPExcel_DocumentSecurity
|
|||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
* @return PHPExcel_DocumentSecurity
|
* @return PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
function setLockStructure($pValue = false) {
|
function setLockStructure($pValue = false)
|
||||||
$this->_lockStructure = $pValue;
|
{
|
||||||
return $this;
|
$this->_lockStructure = $pValue;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,8 +136,9 @@ class PHPExcel_DocumentSecurity
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function getLockWindows() {
|
function getLockWindows()
|
||||||
return $this->_lockWindows;
|
{
|
||||||
|
return $this->_lockWindows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,9 +147,10 @@ class PHPExcel_DocumentSecurity
|
|||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
* @return PHPExcel_DocumentSecurity
|
* @return PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
function setLockWindows($pValue = false) {
|
function setLockWindows($pValue = false)
|
||||||
$this->_lockWindows = $pValue;
|
{
|
||||||
return $this;
|
$this->_lockWindows = $pValue;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,23 +158,25 @@ class PHPExcel_DocumentSecurity
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getRevisionsPassword() {
|
function getRevisionsPassword()
|
||||||
return $this->_revisionsPassword;
|
{
|
||||||
|
return $this->_revisionsPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set RevisionsPassword
|
* Set RevisionsPassword
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||||
* @return PHPExcel_DocumentSecurity
|
* @return PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false) {
|
function setRevisionsPassword($pValue = '', $pAlreadyHashed = false)
|
||||||
if (!$pAlreadyHashed) {
|
{
|
||||||
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
if (!$pAlreadyHashed) {
|
||||||
}
|
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
||||||
$this->_revisionsPassword = $pValue;
|
}
|
||||||
return $this;
|
$this->_revisionsPassword = $pValue;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,36 +184,39 @@ class PHPExcel_DocumentSecurity
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getWorkbookPassword() {
|
function getWorkbookPassword()
|
||||||
return $this->_workbookPassword;
|
{
|
||||||
|
return $this->_workbookPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set WorkbookPassword
|
* Set WorkbookPassword
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
* @param boolean $pAlreadyHashed If the password has already been hashed, set this to true
|
||||||
* @return PHPExcel_DocumentSecurity
|
* @return PHPExcel_DocumentSecurity
|
||||||
*/
|
*/
|
||||||
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false) {
|
function setWorkbookPassword($pValue = '', $pAlreadyHashed = false)
|
||||||
if (!$pAlreadyHashed) {
|
{
|
||||||
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
if (!$pAlreadyHashed) {
|
||||||
}
|
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
|
||||||
$this->_workbookPassword = $pValue;
|
}
|
||||||
return $this;
|
$this->_workbookPassword = $pValue;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
$vars = get_object_vars($this);
|
{
|
||||||
foreach ($vars as $key => $value) {
|
$vars = get_object_vars($this);
|
||||||
if (is_object($value)) {
|
foreach ($vars as $key => $value) {
|
||||||
$this->$key = clone $value;
|
if (is_object($value)) {
|
||||||
} else {
|
$this->$key = clone $value;
|
||||||
$this->$key = $value;
|
} else {
|
||||||
}
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_HashTable
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -19,184 +20,185 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
|
||||||
* @version ##VERSION##, ##DATE##
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_HashTable
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
class PHPExcel_HashTable
|
class PHPExcel_HashTable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* HashTable elements
|
* HashTable elements
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $_items = array();
|
public $_items = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HashTable key map
|
* HashTable key map
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $_keyMap = array();
|
public $_keyMap = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_HashTable
|
* Create a new PHPExcel_HashTable
|
||||||
*
|
*
|
||||||
* @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from
|
* @param PHPExcel_IComparable[] $pSource Optional source array to create HashTable from
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($pSource = null)
|
public function __construct($pSource = null)
|
||||||
{
|
{
|
||||||
if ($pSource !== NULL) {
|
if ($pSource !== null) {
|
||||||
// Create HashTable
|
// Create HashTable
|
||||||
$this->addFromSource($pSource);
|
$this->addFromSource($pSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add HashTable items from source
|
* Add HashTable items from source
|
||||||
*
|
*
|
||||||
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from
|
* @param PHPExcel_IComparable[] $pSource Source array to create HashTable from
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function addFromSource($pSource = null) {
|
public function addFromSource($pSource = null)
|
||||||
// Check if an array was passed
|
{
|
||||||
if ($pSource == null) {
|
// Check if an array was passed
|
||||||
return;
|
if ($pSource == null) {
|
||||||
} else if (!is_array($pSource)) {
|
return;
|
||||||
throw new PHPExcel_Exception('Invalid array parameter passed.');
|
} else if (!is_array($pSource)) {
|
||||||
}
|
throw new PHPExcel_Exception('Invalid array parameter passed.');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($pSource as $item) {
|
foreach ($pSource as $item) {
|
||||||
$this->add($item);
|
$this->add($item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add HashTable item
|
* Add HashTable item
|
||||||
*
|
*
|
||||||
* @param PHPExcel_IComparable $pSource Item to add
|
* @param PHPExcel_IComparable $pSource Item to add
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function add(PHPExcel_IComparable $pSource = null) {
|
public function add(PHPExcel_IComparable $pSource = null)
|
||||||
$hash = $pSource->getHashCode();
|
{
|
||||||
if (!isset($this->_items[$hash])) {
|
$hash = $pSource->getHashCode();
|
||||||
$this->_items[$hash] = $pSource;
|
if (!isset($this->_items[$hash])) {
|
||||||
$this->_keyMap[count($this->_items) - 1] = $hash;
|
$this->_items[$hash] = $pSource;
|
||||||
}
|
$this->_keyMap[count($this->_items) - 1] = $hash;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove HashTable item
|
* Remove HashTable item
|
||||||
*
|
*
|
||||||
* @param PHPExcel_IComparable $pSource Item to remove
|
* @param PHPExcel_IComparable $pSource Item to remove
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function remove(PHPExcel_IComparable $pSource = null) {
|
public function remove(PHPExcel_IComparable $pSource = null)
|
||||||
$hash = $pSource->getHashCode();
|
{
|
||||||
if (isset($this->_items[$hash])) {
|
$hash = $pSource->getHashCode();
|
||||||
unset($this->_items[$hash]);
|
if (isset($this->_items[$hash])) {
|
||||||
|
unset($this->_items[$hash]);
|
||||||
|
|
||||||
$deleteKey = -1;
|
$deleteKey = -1;
|
||||||
foreach ($this->_keyMap as $key => $value) {
|
foreach ($this->_keyMap as $key => $value) {
|
||||||
if ($deleteKey >= 0) {
|
if ($deleteKey >= 0) {
|
||||||
$this->_keyMap[$key - 1] = $value;
|
$this->_keyMap[$key - 1] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value == $hash) {
|
if ($value == $hash) {
|
||||||
$deleteKey = $key;
|
$deleteKey = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($this->_keyMap[count($this->_keyMap) - 1]);
|
unset($this->_keyMap[count($this->_keyMap) - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear HashTable
|
* Clear HashTable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function clear() {
|
public function clear()
|
||||||
$this->_items = array();
|
{
|
||||||
$this->_keyMap = array();
|
$this->_items = array();
|
||||||
}
|
$this->_keyMap = array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count
|
* Count
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function count() {
|
public function count()
|
||||||
return count($this->_items);
|
{
|
||||||
}
|
return count($this->_items);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get index for hash code
|
* Get index for hash code
|
||||||
*
|
*
|
||||||
* @param string $pHashCode
|
* @param string $pHashCode
|
||||||
* @return int Index
|
* @return int Index
|
||||||
*/
|
*/
|
||||||
public function getIndexForHashCode($pHashCode = '') {
|
public function getIndexForHashCode($pHashCode = '')
|
||||||
return array_search($pHashCode, $this->_keyMap);
|
{
|
||||||
}
|
return array_search($pHashCode, $this->_keyMap);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get by index
|
* Get by index
|
||||||
*
|
*
|
||||||
* @param int $pIndex
|
* @param int $pIndex
|
||||||
* @return PHPExcel_IComparable
|
* @return PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getByIndex($pIndex = 0) {
|
public function getByIndex($pIndex = 0)
|
||||||
if (isset($this->_keyMap[$pIndex])) {
|
{
|
||||||
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
if (isset($this->_keyMap[$pIndex])) {
|
||||||
}
|
return $this->getByHashCode( $this->_keyMap[$pIndex] );
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get by hashcode
|
* Get by hashcode
|
||||||
*
|
*
|
||||||
* @param string $pHashCode
|
* @param string $pHashCode
|
||||||
* @return PHPExcel_IComparable
|
* @return PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function getByHashCode($pHashCode = '') {
|
public function getByHashCode($pHashCode = '')
|
||||||
if (isset($this->_items[$pHashCode])) {
|
{
|
||||||
return $this->_items[$pHashCode];
|
if (isset($this->_items[$pHashCode])) {
|
||||||
}
|
return $this->_items[$pHashCode];
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HashTable to array
|
* HashTable to array
|
||||||
*
|
*
|
||||||
* @return PHPExcel_IComparable[]
|
* @return PHPExcel_IComparable[]
|
||||||
*/
|
*/
|
||||||
public function toArray() {
|
public function toArray()
|
||||||
return $this->_items;
|
{
|
||||||
}
|
return $this->_items;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone()
|
||||||
$vars = get_object_vars($this);
|
{
|
||||||
foreach ($vars as $key => $value) {
|
$vars = get_object_vars($this);
|
||||||
if (is_object($value)) {
|
foreach ($vars as $key => $value) {
|
||||||
$this->$key = clone $value;
|
if (is_object($value)) {
|
||||||
}
|
$this->$key = clone $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_IComparable
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -19,25 +20,16 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_IComparable
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
interface PHPExcel_IComparable
|
interface PHPExcel_IComparable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get hash code
|
* Get hash code
|
||||||
*
|
*
|
||||||
* @return string Hash code
|
* @return string Hash code
|
||||||
*/
|
*/
|
||||||
public function getHashCode();
|
public function getHashCode();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/** PHPExcel root directory */
|
||||||
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
||||||
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_IOFactory
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,268 +31,257 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel root directory */
|
|
||||||
if (!defined('PHPEXCEL_ROOT')) {
|
|
||||||
/**
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
|
|
||||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_IOFactory
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_IOFactory
|
class PHPExcel_IOFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Search locations
|
* Search locations
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
private static $_searchLocations = array(
|
private static $_searchLocations = array(
|
||||||
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
|
array( 'type' => 'IWriter', 'path' => 'PHPExcel/Writer/{0}.php', 'class' => 'PHPExcel_Writer_{0}' ),
|
||||||
array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{0}' )
|
array( 'type' => 'IReader', 'path' => 'PHPExcel/Reader/{0}.php', 'class' => 'PHPExcel_Reader_{0}' )
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* Autoresolve classes
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @access private
|
|
||||||
* @static
|
|
||||||
*/
|
|
||||||
private static $_autoResolveClasses = array(
|
|
||||||
'Excel2007',
|
|
||||||
'Excel5',
|
|
||||||
'Excel2003XML',
|
|
||||||
'OOCalc',
|
|
||||||
'SYLK',
|
|
||||||
'Gnumeric',
|
|
||||||
'HTML',
|
|
||||||
'CSV',
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private constructor for PHPExcel_IOFactory
|
* Autoresolve classes
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
private static $_autoResolveClasses = array(
|
||||||
|
'Excel2007',
|
||||||
|
'Excel5',
|
||||||
|
'Excel2003XML',
|
||||||
|
'OOCalc',
|
||||||
|
'SYLK',
|
||||||
|
'Gnumeric',
|
||||||
|
'HTML',
|
||||||
|
'CSV',
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private constructor for PHPExcel_IOFactory
|
||||||
*/
|
*/
|
||||||
private function __construct() { }
|
private function __construct() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get search locations
|
* Get search locations
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getSearchLocations() {
|
public static function getSearchLocations()
|
||||||
return self::$_searchLocations;
|
{
|
||||||
} // function getSearchLocations()
|
return self::$_searchLocations;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set search locations
|
* Set search locations
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $value
|
* @param array $value
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function setSearchLocations($value) {
|
public static function setSearchLocations($value)
|
||||||
if (is_array($value)) {
|
{
|
||||||
self::$_searchLocations = $value;
|
if (is_array($value)) {
|
||||||
} else {
|
self::$_searchLocations = $value;
|
||||||
throw new PHPExcel_Reader_Exception('Invalid parameter passed.');
|
} else {
|
||||||
}
|
throw new PHPExcel_Reader_Exception('Invalid parameter passed.');
|
||||||
} // function setSearchLocations()
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add search location
|
* Add search location
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $type Example: IWriter
|
* @param string $type Example: IWriter
|
||||||
* @param string $location Example: PHPExcel/Writer/{0}.php
|
* @param string $location Example: PHPExcel/Writer/{0}.php
|
||||||
* @param string $classname Example: PHPExcel_Writer_{0}
|
* @param string $classname Example: PHPExcel_Writer_{0}
|
||||||
*/
|
*/
|
||||||
public static function addSearchLocation($type = '', $location = '', $classname = '') {
|
public static function addSearchLocation($type = '', $location = '', $classname = '')
|
||||||
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
{
|
||||||
} // function addSearchLocation()
|
self::$_searchLocations[] = array( 'type' => $type, 'path' => $location, 'class' => $classname );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create PHPExcel_Writer_IWriter
|
* Create PHPExcel_Writer_IWriter
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param PHPExcel $phpExcel
|
* @param PHPExcel $phpExcel
|
||||||
* @param string $writerType Example: Excel2007
|
* @param string $writerType Example: Excel2007
|
||||||
* @return PHPExcel_Writer_IWriter
|
* @return PHPExcel_Writer_IWriter
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function createWriter(PHPExcel $phpExcel, $writerType = '') {
|
public static function createWriter(PHPExcel $phpExcel, $writerType = '')
|
||||||
// Search type
|
{
|
||||||
$searchType = 'IWriter';
|
// Search type
|
||||||
|
$searchType = 'IWriter';
|
||||||
|
|
||||||
// Include class
|
// Include class
|
||||||
foreach (self::$_searchLocations as $searchLocation) {
|
foreach (self::$_searchLocations as $searchLocation) {
|
||||||
if ($searchLocation['type'] == $searchType) {
|
if ($searchLocation['type'] == $searchType) {
|
||||||
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
$className = str_replace('{0}', $writerType, $searchLocation['class']);
|
||||||
|
|
||||||
$instance = new $className($phpExcel);
|
$instance = new $className($phpExcel);
|
||||||
if ($instance !== NULL) {
|
if ($instance !== NULL) {
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing found...
|
// Nothing found...
|
||||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
|
throw new PHPExcel_Reader_Exception("No $searchType found for type $writerType");
|
||||||
} // function createWriter()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create PHPExcel_Reader_IReader
|
* Create PHPExcel_Reader_IReader
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $readerType Example: Excel2007
|
* @param string $readerType Example: Excel2007
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function createReader($readerType = '') {
|
public static function createReader($readerType = '')
|
||||||
// Search type
|
{
|
||||||
$searchType = 'IReader';
|
// Search type
|
||||||
|
$searchType = 'IReader';
|
||||||
|
|
||||||
// Include class
|
// Include class
|
||||||
foreach (self::$_searchLocations as $searchLocation) {
|
foreach (self::$_searchLocations as $searchLocation) {
|
||||||
if ($searchLocation['type'] == $searchType) {
|
if ($searchLocation['type'] == $searchType) {
|
||||||
$className = str_replace('{0}', $readerType, $searchLocation['class']);
|
$className = str_replace('{0}', $readerType, $searchLocation['class']);
|
||||||
|
|
||||||
$instance = new $className();
|
$instance = new $className();
|
||||||
if ($instance !== NULL) {
|
if ($instance !== NULL) {
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing found...
|
// Nothing found...
|
||||||
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
|
throw new PHPExcel_Reader_Exception("No $searchType found for type $readerType");
|
||||||
} // function createReader()
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
|
* Loads PHPExcel from file using automatic PHPExcel_Reader_IReader resolution
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $pFilename The name of the spreadsheet file
|
* @param string $pFilename The name of the spreadsheet file
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function load($pFilename) {
|
public static function load($pFilename)
|
||||||
$reader = self::createReaderForFile($pFilename);
|
{
|
||||||
return $reader->load($pFilename);
|
$reader = self::createReaderForFile($pFilename);
|
||||||
} // function load()
|
return $reader->load($pFilename);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identify file type using automatic PHPExcel_Reader_IReader resolution
|
* Identify file type using automatic PHPExcel_Reader_IReader resolution
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $pFilename The name of the spreadsheet file to identify
|
* @param string $pFilename The name of the spreadsheet file to identify
|
||||||
* @return string
|
* @return string
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function identify($pFilename) {
|
public static function identify($pFilename)
|
||||||
$reader = self::createReaderForFile($pFilename);
|
{
|
||||||
$className = get_class($reader);
|
$reader = self::createReaderForFile($pFilename);
|
||||||
$classType = explode('_',$className);
|
$className = get_class($reader);
|
||||||
unset($reader);
|
$classType = explode('_',$className);
|
||||||
return array_pop($classType);
|
unset($reader);
|
||||||
} // function identify()
|
return array_pop($classType);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
|
* Create PHPExcel_Reader_IReader for file using automatic PHPExcel_Reader_IReader resolution
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $pFilename The name of the spreadsheet file
|
* @param string $pFilename The name of the spreadsheet file
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public static function createReaderForFile($pFilename) {
|
public static function createReaderForFile($pFilename)
|
||||||
|
{
|
||||||
|
// First, lucky guess by inspecting file extension
|
||||||
|
$pathinfo = pathinfo($pFilename);
|
||||||
|
|
||||||
// First, lucky guess by inspecting file extension
|
$extensionType = NULL;
|
||||||
$pathinfo = pathinfo($pFilename);
|
if (isset($pathinfo['extension'])) {
|
||||||
|
switch (strtolower($pathinfo['extension'])) {
|
||||||
|
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
|
||||||
|
case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded)
|
||||||
|
case 'xltx': // Excel (OfficeOpenXML) Template
|
||||||
|
case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
|
||||||
|
$extensionType = 'Excel2007';
|
||||||
|
break;
|
||||||
|
case 'xls': // Excel (BIFF) Spreadsheet
|
||||||
|
case 'xlt': // Excel (BIFF) Template
|
||||||
|
$extensionType = 'Excel5';
|
||||||
|
break;
|
||||||
|
case 'ods': // Open/Libre Offic Calc
|
||||||
|
case 'ots': // Open/Libre Offic Calc Template
|
||||||
|
$extensionType = 'OOCalc';
|
||||||
|
break;
|
||||||
|
case 'slk':
|
||||||
|
$extensionType = 'SYLK';
|
||||||
|
break;
|
||||||
|
case 'xml': // Excel 2003 SpreadSheetML
|
||||||
|
$extensionType = 'Excel2003XML';
|
||||||
|
break;
|
||||||
|
case 'gnumeric':
|
||||||
|
$extensionType = 'Gnumeric';
|
||||||
|
break;
|
||||||
|
case 'htm':
|
||||||
|
case 'html':
|
||||||
|
$extensionType = 'HTML';
|
||||||
|
break;
|
||||||
|
case 'csv':
|
||||||
|
// Do nothing
|
||||||
|
// We must not try to use CSV reader since it loads
|
||||||
|
// all files including Excel files etc.
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$extensionType = NULL;
|
if ($extensionType !== null) {
|
||||||
if (isset($pathinfo['extension'])) {
|
$reader = self::createReader($extensionType);
|
||||||
switch (strtolower($pathinfo['extension'])) {
|
// Let's see if we are lucky
|
||||||
case 'xlsx': // Excel (OfficeOpenXML) Spreadsheet
|
if (isset($reader) && $reader->canRead($pFilename)) {
|
||||||
case 'xlsm': // Excel (OfficeOpenXML) Macro Spreadsheet (macros will be discarded)
|
return $reader;
|
||||||
case 'xltx': // Excel (OfficeOpenXML) Template
|
}
|
||||||
case 'xltm': // Excel (OfficeOpenXML) Macro Template (macros will be discarded)
|
}
|
||||||
$extensionType = 'Excel2007';
|
}
|
||||||
break;
|
|
||||||
case 'xls': // Excel (BIFF) Spreadsheet
|
|
||||||
case 'xlt': // Excel (BIFF) Template
|
|
||||||
$extensionType = 'Excel5';
|
|
||||||
break;
|
|
||||||
case 'ods': // Open/Libre Offic Calc
|
|
||||||
case 'ots': // Open/Libre Offic Calc Template
|
|
||||||
$extensionType = 'OOCalc';
|
|
||||||
break;
|
|
||||||
case 'slk':
|
|
||||||
$extensionType = 'SYLK';
|
|
||||||
break;
|
|
||||||
case 'xml': // Excel 2003 SpreadSheetML
|
|
||||||
$extensionType = 'Excel2003XML';
|
|
||||||
break;
|
|
||||||
case 'gnumeric':
|
|
||||||
$extensionType = 'Gnumeric';
|
|
||||||
break;
|
|
||||||
case 'htm':
|
|
||||||
case 'html':
|
|
||||||
$extensionType = 'HTML';
|
|
||||||
break;
|
|
||||||
case 'csv':
|
|
||||||
// Do nothing
|
|
||||||
// We must not try to use CSV reader since it loads
|
|
||||||
// all files including Excel files etc.
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($extensionType !== NULL) {
|
// If we reach here then "lucky guess" didn't give any result
|
||||||
$reader = self::createReader($extensionType);
|
// Try walking through all the options in self::$_autoResolveClasses
|
||||||
// Let's see if we are lucky
|
foreach (self::$_autoResolveClasses as $autoResolveClass) {
|
||||||
if (isset($reader) && $reader->canRead($pFilename)) {
|
// Ignore our original guess, we know that won't work
|
||||||
return $reader;
|
if ($autoResolveClass !== $extensionType) {
|
||||||
}
|
$reader = self::createReader($autoResolveClass);
|
||||||
}
|
if ($reader->canRead($pFilename)) {
|
||||||
}
|
return $reader;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we reach here then "lucky guess" didn't give any result
|
throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file');
|
||||||
// Try walking through all the options in self::$_autoResolveClasses
|
}
|
||||||
foreach (self::$_autoResolveClasses as $autoResolveClass) {
|
|
||||||
// Ignore our original guess, we know that won't work
|
|
||||||
if ($autoResolveClass !== $extensionType) {
|
|
||||||
$reader = self::createReader($autoResolveClass);
|
|
||||||
if ($reader->canRead($pFilename)) {
|
|
||||||
return $reader;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new PHPExcel_Reader_Exception('Unable to identify a reader for this file');
|
|
||||||
} // function createReaderForFile()
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_NamedRange
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,54 +22,45 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel
|
* @package PHPExcel
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_NamedRange
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_NamedRange
|
class PHPExcel_NamedRange
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Range name
|
* Range name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_name;
|
private $_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Worksheet on which the named range can be resolved
|
* Worksheet on which the named range can be resolved
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Worksheet
|
* @var PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
private $_worksheet;
|
private $_worksheet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Range of the referenced cells
|
* Range of the referenced cells
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_range;
|
private $_range;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the named range local? (i.e. can only be used on $this->_worksheet)
|
* Is the named range local? (i.e. can only be used on $this->_worksheet)
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $_localOnly;
|
private $_localOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scope
|
* Scope
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Worksheet
|
* @var PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
private $_scope;
|
private $_scope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new NamedRange
|
* Create a new NamedRange
|
||||||
@ -77,23 +69,23 @@ class PHPExcel_NamedRange
|
|||||||
* @param PHPExcel_Worksheet $pWorksheet
|
* @param PHPExcel_Worksheet $pWorksheet
|
||||||
* @param string $pRange
|
* @param string $pRange
|
||||||
* @param bool $pLocalOnly
|
* @param bool $pLocalOnly
|
||||||
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
|
* @param PHPExcel_Worksheet|null $pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
|
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
|
||||||
{
|
{
|
||||||
// Validate data
|
// Validate data
|
||||||
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
|
if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
|
||||||
throw new PHPExcel_Exception('Parameters can not be null.');
|
throw new PHPExcel_Exception('Parameters can not be null.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set local members
|
// Set local members
|
||||||
$this->_name = $pName;
|
$this->_name = $pName;
|
||||||
$this->_worksheet = $pWorksheet;
|
$this->_worksheet = $pWorksheet;
|
||||||
$this->_range = $pRange;
|
$this->_range = $pRange;
|
||||||
$this->_localOnly = $pLocalOnly;
|
$this->_localOnly = $pLocalOnly;
|
||||||
$this->_scope = ($pLocalOnly == true) ?
|
$this->_scope = ($pLocalOnly == true) ?
|
||||||
(($pScope == null) ? $pWorksheet : $pScope) : null;
|
(($pScope == null) ? $pWorksheet : $pScope) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,7 +94,7 @@ class PHPExcel_NamedRange
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName() {
|
public function getName() {
|
||||||
return $this->_name;
|
return $this->_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,25 +104,25 @@ class PHPExcel_NamedRange
|
|||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public function setName($value = null) {
|
public function setName($value = null) {
|
||||||
if ($value !== NULL) {
|
if ($value !== NULL) {
|
||||||
// Old title
|
// Old title
|
||||||
$oldTitle = $this->_name;
|
$oldTitle = $this->_name;
|
||||||
|
|
||||||
// Re-attach
|
// Re-attach
|
||||||
if ($this->_worksheet !== NULL) {
|
if ($this->_worksheet !== NULL) {
|
||||||
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
|
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
|
||||||
}
|
}
|
||||||
$this->_name = $value;
|
$this->_name = $value;
|
||||||
|
|
||||||
if ($this->_worksheet !== NULL) {
|
if ($this->_worksheet !== NULL) {
|
||||||
$this->_worksheet->getParent()->addNamedRange($this);
|
$this->_worksheet->getParent()->addNamedRange($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// New title
|
// New title
|
||||||
$newTitle = $this->_name;
|
$newTitle = $this->_name;
|
||||||
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle);
|
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,7 +131,7 @@ class PHPExcel_NamedRange
|
|||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function getWorksheet() {
|
public function getWorksheet() {
|
||||||
return $this->_worksheet;
|
return $this->_worksheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,10 +141,10 @@ class PHPExcel_NamedRange
|
|||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public function setWorksheet(PHPExcel_Worksheet $value = null) {
|
public function setWorksheet(PHPExcel_Worksheet $value = null) {
|
||||||
if ($value !== NULL) {
|
if ($value !== NULL) {
|
||||||
$this->_worksheet = $value;
|
$this->_worksheet = $value;
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,7 +153,7 @@ class PHPExcel_NamedRange
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getRange() {
|
public function getRange() {
|
||||||
return $this->_range;
|
return $this->_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,10 +163,10 @@ class PHPExcel_NamedRange
|
|||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public function setRange($value = null) {
|
public function setRange($value = null) {
|
||||||
if ($value !== NULL) {
|
if ($value !== NULL) {
|
||||||
$this->_range = $value;
|
$this->_range = $value;
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,7 +175,7 @@ class PHPExcel_NamedRange
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function getLocalOnly() {
|
public function getLocalOnly() {
|
||||||
return $this->_localOnly;
|
return $this->_localOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,9 +185,9 @@ class PHPExcel_NamedRange
|
|||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public function setLocalOnly($value = false) {
|
public function setLocalOnly($value = false) {
|
||||||
$this->_localOnly = $value;
|
$this->_localOnly = $value;
|
||||||
$this->_scope = $value ? $this->_worksheet : null;
|
$this->_scope = $value ? $this->_worksheet : null;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,7 +196,7 @@ class PHPExcel_NamedRange
|
|||||||
* @return PHPExcel_Worksheet|null
|
* @return PHPExcel_Worksheet|null
|
||||||
*/
|
*/
|
||||||
public function getScope() {
|
public function getScope() {
|
||||||
return $this->_scope;
|
return $this->_scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -214,9 +206,9 @@ class PHPExcel_NamedRange
|
|||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public function setScope(PHPExcel_Worksheet $value = null) {
|
public function setScope(PHPExcel_Worksheet $value = null) {
|
||||||
$this->_scope = $value;
|
$this->_scope = $value;
|
||||||
$this->_localOnly = ($value == null) ? false : true;
|
$this->_localOnly = ($value == null) ? false : true;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,20 +219,20 @@ class PHPExcel_NamedRange
|
|||||||
* @return PHPExcel_NamedRange
|
* @return PHPExcel_NamedRange
|
||||||
*/
|
*/
|
||||||
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {
|
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {
|
||||||
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
|
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone() {
|
||||||
$vars = get_object_vars($this);
|
$vars = get_object_vars($this);
|
||||||
foreach ($vars as $key => $value) {
|
foreach ($vars as $key => $value) {
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
$this->$key = clone $value;
|
$this->$key = clone $value;
|
||||||
} else {
|
} else {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -29,212 +29,212 @@
|
|||||||
/**
|
/**
|
||||||
* PHPExcel_Reader_Abstract
|
* PHPExcel_Reader_Abstract
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Read data only?
|
* Read data only?
|
||||||
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
|
* Identifies whether the Reader should only read data values for cells, and ignore any formatting information;
|
||||||
* or whether it should read both data and formatting
|
* or whether it should read both data and formatting
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $_readDataOnly = FALSE;
|
protected $_readDataOnly = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read charts that are defined in the workbook?
|
* Read charts that are defined in the workbook?
|
||||||
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
|
* Identifies whether the Reader should read the definitions for any charts that exist in the workbook;
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $_includeCharts = FALSE;
|
protected $_includeCharts = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restrict which sheets should be loaded?
|
* Restrict which sheets should be loaded?
|
||||||
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
|
* This property holds an array of worksheet names to be loaded. If null, then all worksheets will be loaded.
|
||||||
*
|
*
|
||||||
* @var array of string
|
* @var array of string
|
||||||
*/
|
*/
|
||||||
protected $_loadSheetsOnly = NULL;
|
protected $_loadSheetsOnly = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Reader_IReadFilter instance
|
* PHPExcel_Reader_IReadFilter instance
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Reader_IReadFilter
|
* @var PHPExcel_Reader_IReadFilter
|
||||||
*/
|
*/
|
||||||
protected $_readFilter = NULL;
|
protected $_readFilter = NULL;
|
||||||
|
|
||||||
protected $_fileHandle = NULL;
|
protected $_fileHandle = NULL;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read data only?
|
* Read data only?
|
||||||
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
|
* If this is true, then the Reader will only read data values for cells, it will not read any formatting information.
|
||||||
* If false (the default) it will read data and formatting.
|
* If false (the default) it will read data and formatting.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getReadDataOnly() {
|
public function getReadDataOnly() {
|
||||||
return $this->_readDataOnly;
|
return $this->_readDataOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set read data only
|
* Set read data only
|
||||||
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
|
* Set to true, to advise the Reader only to read data values for cells, and to ignore any formatting information.
|
||||||
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
|
* Set to false (the default) to advise the Reader to read both data and formatting for cells.
|
||||||
*
|
*
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
*/
|
*/
|
||||||
public function setReadDataOnly($pValue = FALSE) {
|
public function setReadDataOnly($pValue = FALSE) {
|
||||||
$this->_readDataOnly = $pValue;
|
$this->_readDataOnly = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read charts in workbook?
|
* Read charts in workbook?
|
||||||
* If this is true, then the Reader will include any charts that exist in the workbook.
|
* If this is true, then the Reader will include any charts that exist in the workbook.
|
||||||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||||
* If false (the default) it will ignore any charts defined in the workbook file.
|
* If false (the default) it will ignore any charts defined in the workbook file.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getIncludeCharts() {
|
public function getIncludeCharts() {
|
||||||
return $this->_includeCharts;
|
return $this->_includeCharts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set read charts in workbook
|
* Set read charts in workbook
|
||||||
* Set to true, to advise the Reader to include any charts that exist in the workbook.
|
* Set to true, to advise the Reader to include any charts that exist in the workbook.
|
||||||
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
* Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value.
|
||||||
* Set to false (the default) to discard charts.
|
* Set to false (the default) to discard charts.
|
||||||
*
|
*
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
*/
|
*/
|
||||||
public function setIncludeCharts($pValue = FALSE) {
|
public function setIncludeCharts($pValue = FALSE) {
|
||||||
$this->_includeCharts = (boolean) $pValue;
|
$this->_includeCharts = (boolean) $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get which sheets to load
|
* Get which sheets to load
|
||||||
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
|
* Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null
|
||||||
* indicating that all worksheets in the workbook should be loaded.
|
* indicating that all worksheets in the workbook should be loaded.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getLoadSheetsOnly()
|
public function getLoadSheetsOnly()
|
||||||
{
|
{
|
||||||
return $this->_loadSheetsOnly;
|
return $this->_loadSheetsOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set which sheets to load
|
* Set which sheets to load
|
||||||
*
|
*
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
|
* This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name.
|
||||||
* If NULL, then it tells the Reader to read all worksheets in the workbook
|
* If NULL, then it tells the Reader to read all worksheets in the workbook
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
*/
|
*/
|
||||||
public function setLoadSheetsOnly($value = NULL)
|
public function setLoadSheetsOnly($value = NULL)
|
||||||
{
|
{
|
||||||
if ($value === NULL)
|
if ($value === NULL)
|
||||||
return $this->setLoadAllSheets();
|
return $this->setLoadAllSheets();
|
||||||
|
|
||||||
$this->_loadSheetsOnly = is_array($value) ?
|
$this->_loadSheetsOnly = is_array($value) ?
|
||||||
$value : array($value);
|
$value : array($value);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set all sheets to load
|
* Set all sheets to load
|
||||||
* Tells the Reader to load all worksheets from the workbook.
|
* Tells the Reader to load all worksheets from the workbook.
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
*/
|
*/
|
||||||
public function setLoadAllSheets()
|
public function setLoadAllSheets()
|
||||||
{
|
{
|
||||||
$this->_loadSheetsOnly = NULL;
|
$this->_loadSheetsOnly = NULL;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read filter
|
* Read filter
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Reader_IReadFilter
|
* @return PHPExcel_Reader_IReadFilter
|
||||||
*/
|
*/
|
||||||
public function getReadFilter() {
|
public function getReadFilter() {
|
||||||
return $this->_readFilter;
|
return $this->_readFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set read filter
|
* Set read filter
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Reader_IReadFilter $pValue
|
* @param PHPExcel_Reader_IReadFilter $pValue
|
||||||
* @return PHPExcel_Reader_IReader
|
* @return PHPExcel_Reader_IReader
|
||||||
*/
|
*/
|
||||||
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
|
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
|
||||||
$this->_readFilter = $pValue;
|
$this->_readFilter = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open file for reading
|
* Open file for reading
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
protected function _openFile($pFilename)
|
protected function _openFile($pFilename)
|
||||||
{
|
{
|
||||||
// Check if file exists
|
// Check if file exists
|
||||||
if (!file_exists($pFilename) || !is_readable($pFilename)) {
|
if (!file_exists($pFilename) || !is_readable($pFilename)) {
|
||||||
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
$this->_fileHandle = fopen($pFilename, 'r');
|
$this->_fileHandle = fopen($pFilename, 'r');
|
||||||
if ($this->_fileHandle === FALSE) {
|
if ($this->_fileHandle === FALSE) {
|
||||||
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
|
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can the current PHPExcel_Reader_IReader read the file?
|
* Can the current PHPExcel_Reader_IReader read the file?
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function canRead($pFilename)
|
public function canRead($pFilename)
|
||||||
{
|
{
|
||||||
// Check if file exists
|
// Check if file exists
|
||||||
try {
|
try {
|
||||||
$this->_openFile($pFilename);
|
$this->_openFile($pFilename);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$readable = $this->_isValidFormat();
|
$readable = $this->_isValidFormat();
|
||||||
fclose ($this->_fileHandle);
|
fclose ($this->_fileHandle);
|
||||||
return $readable;
|
return $readable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param string $xml
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function securityScan($xml)
|
public function securityScan($xml)
|
||||||
{
|
{
|
||||||
$pattern = '/\\0?' . implode('\\0?', str_split('<!DOCTYPE')) . '\\0?/';
|
$pattern = '/\\0?' . implode('\\0?', str_split('<!DOCTYPE')) . '\\0?/';
|
||||||
if (preg_match($pattern, $xml)) {
|
if (preg_match($pattern, $xml)) {
|
||||||
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
||||||
@ -242,14 +242,14 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
|||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
||||||
*
|
*
|
||||||
* @param string $filestream
|
* @param string $filestream
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function securityScanFile($filestream)
|
public function securityScanFile($filestream)
|
||||||
{
|
{
|
||||||
return $this->securityScan(file_get_contents($filestream));
|
return $this->securityScan(file_get_contents($filestream));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,18 +21,18 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel root directory */
|
/** PHPExcel root directory */
|
||||||
if (!defined('PHPEXCEL_ROOT')) {
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,344 +44,344 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Input encoding
|
* Input encoding
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_inputEncoding = 'UTF-8';
|
private $_inputEncoding = 'UTF-8';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delimiter
|
* Delimiter
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_delimiter = ',';
|
private $_delimiter = ',';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enclosure
|
* Enclosure
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_enclosure = '"';
|
private $_enclosure = '"';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sheet index to read
|
* Sheet index to read
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_sheetIndex = 0;
|
private $_sheetIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load rows contiguously
|
* Load rows contiguously
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_contiguous = false;
|
private $_contiguous = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Row counter for loading rows contiguously
|
* Row counter for loading rows contiguously
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_contiguousRow = -1;
|
private $_contiguousRow = -1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Reader_CSV
|
* Create a new PHPExcel_Reader_CSV
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that the current file is a CSV file
|
* Validate that the current file is a CSV file
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function _isValidFormat()
|
protected function _isValidFormat()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set input encoding
|
* Set input encoding
|
||||||
*
|
*
|
||||||
* @param string $pValue Input encoding
|
* @param string $pValue Input encoding
|
||||||
*/
|
*/
|
||||||
public function setInputEncoding($pValue = 'UTF-8')
|
public function setInputEncoding($pValue = 'UTF-8')
|
||||||
{
|
{
|
||||||
$this->_inputEncoding = $pValue;
|
$this->_inputEncoding = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get input encoding
|
* Get input encoding
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getInputEncoding()
|
public function getInputEncoding()
|
||||||
{
|
{
|
||||||
return $this->_inputEncoding;
|
return $this->_inputEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move filepointer past any BOM marker
|
* Move filepointer past any BOM marker
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function _skipBOM()
|
protected function _skipBOM()
|
||||||
{
|
{
|
||||||
rewind($this->_fileHandle);
|
rewind($this->_fileHandle);
|
||||||
|
|
||||||
switch ($this->_inputEncoding) {
|
switch ($this->_inputEncoding) {
|
||||||
case 'UTF-8':
|
case 'UTF-8':
|
||||||
fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ?
|
fgets($this->_fileHandle, 4) == "\xEF\xBB\xBF" ?
|
||||||
fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0);
|
fseek($this->_fileHandle, 3) : fseek($this->_fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-16LE':
|
case 'UTF-16LE':
|
||||||
fgets($this->_fileHandle, 3) == "\xFF\xFE" ?
|
fgets($this->_fileHandle, 3) == "\xFF\xFE" ?
|
||||||
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-16BE':
|
case 'UTF-16BE':
|
||||||
fgets($this->_fileHandle, 3) == "\xFE\xFF" ?
|
fgets($this->_fileHandle, 3) == "\xFE\xFF" ?
|
||||||
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
fseek($this->_fileHandle, 2) : fseek($this->_fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-32LE':
|
case 'UTF-32LE':
|
||||||
fgets($this->_fileHandle, 5) == "\xFF\xFE\x00\x00" ?
|
fgets($this->_fileHandle, 5) == "\xFF\xFE\x00\x00" ?
|
||||||
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
case 'UTF-32BE':
|
case 'UTF-32BE':
|
||||||
fgets($this->_fileHandle, 5) == "\x00\x00\xFE\xFF" ?
|
fgets($this->_fileHandle, 5) == "\x00\x00\xFE\xFF" ?
|
||||||
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
fseek($this->_fileHandle, 4) : fseek($this->_fileHandle, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function listWorksheetInfo($pFilename)
|
public function listWorksheetInfo($pFilename)
|
||||||
{
|
{
|
||||||
// Open file
|
// Open file
|
||||||
$this->_openFile($pFilename);
|
$this->_openFile($pFilename);
|
||||||
if (!$this->_isValidFormat()) {
|
if (!$this->_isValidFormat()) {
|
||||||
fclose ($this->_fileHandle);
|
fclose ($this->_fileHandle);
|
||||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||||
}
|
}
|
||||||
$fileHandle = $this->_fileHandle;
|
$fileHandle = $this->_fileHandle;
|
||||||
|
|
||||||
// Skip BOM, if any
|
// Skip BOM, if any
|
||||||
$this->_skipBOM();
|
$this->_skipBOM();
|
||||||
|
|
||||||
$escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure );
|
$escapeEnclosures = array( "\\" . $this->_enclosure, $this->_enclosure . $this->_enclosure );
|
||||||
|
|
||||||
$worksheetInfo = array();
|
$worksheetInfo = array();
|
||||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||||
$worksheetInfo[0]['totalRows'] = 0;
|
$worksheetInfo[0]['totalRows'] = 0;
|
||||||
$worksheetInfo[0]['totalColumns'] = 0;
|
$worksheetInfo[0]['totalColumns'] = 0;
|
||||||
|
|
||||||
// Loop through each line of the file in turn
|
// Loop through each line of the file in turn
|
||||||
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
|
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
|
||||||
$worksheetInfo[0]['totalRows']++;
|
$worksheetInfo[0]['totalRows']++;
|
||||||
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
|
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], count($rowData) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
||||||
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
fclose($fileHandle);
|
fclose($fileHandle);
|
||||||
|
|
||||||
return $worksheetInfo;
|
return $worksheetInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file
|
* Loads PHPExcel from file
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function load($pFilename)
|
public function load($pFilename)
|
||||||
{
|
{
|
||||||
// Create new PHPExcel
|
// Create new PHPExcel
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Load into this instance
|
// Load into this instance
|
||||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file into PHPExcel instance
|
* Loads PHPExcel from file into PHPExcel instance
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @param PHPExcel $objPHPExcel
|
* @param PHPExcel $objPHPExcel
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||||
{
|
{
|
||||||
$lineEnding = ini_get('auto_detect_line_endings');
|
$lineEnding = ini_get('auto_detect_line_endings');
|
||||||
ini_set('auto_detect_line_endings', true);
|
ini_set('auto_detect_line_endings', true);
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
$this->_openFile($pFilename);
|
$this->_openFile($pFilename);
|
||||||
if (!$this->_isValidFormat()) {
|
if (!$this->_isValidFormat()) {
|
||||||
fclose ($this->_fileHandle);
|
fclose ($this->_fileHandle);
|
||||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||||
}
|
}
|
||||||
$fileHandle = $this->_fileHandle;
|
$fileHandle = $this->_fileHandle;
|
||||||
|
|
||||||
// Skip BOM, if any
|
// Skip BOM, if any
|
||||||
$this->_skipBOM();
|
$this->_skipBOM();
|
||||||
|
|
||||||
// Create new PHPExcel object
|
// Create new PHPExcel object
|
||||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
||||||
$objPHPExcel->createSheet();
|
$objPHPExcel->createSheet();
|
||||||
}
|
}
|
||||||
$sheet = $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
|
$sheet = $objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
|
||||||
|
|
||||||
$escapeEnclosures = array( "\\" . $this->_enclosure,
|
$escapeEnclosures = array( "\\" . $this->_enclosure,
|
||||||
$this->_enclosure . $this->_enclosure
|
$this->_enclosure . $this->_enclosure
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set our starting row based on whether we're in contiguous mode or not
|
// Set our starting row based on whether we're in contiguous mode or not
|
||||||
$currentRow = 1;
|
$currentRow = 1;
|
||||||
if ($this->_contiguous) {
|
if ($this->_contiguous) {
|
||||||
$currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow;
|
$currentRow = ($this->_contiguousRow == -1) ? $sheet->getHighestRow(): $this->_contiguousRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through each line of the file in turn
|
// Loop through each line of the file in turn
|
||||||
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
|
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
|
||||||
$columnLetter = 'A';
|
$columnLetter = 'A';
|
||||||
foreach($rowData as $rowDatum) {
|
foreach($rowData as $rowDatum) {
|
||||||
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
|
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
|
||||||
// Unescape enclosures
|
// Unescape enclosures
|
||||||
$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);
|
$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);
|
||||||
|
|
||||||
// Convert encoding if necessary
|
// Convert encoding if necessary
|
||||||
if ($this->_inputEncoding !== 'UTF-8') {
|
if ($this->_inputEncoding !== 'UTF-8') {
|
||||||
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
|
$rowDatum = PHPExcel_Shared_String::ConvertEncoding($rowDatum, 'UTF-8', $this->_inputEncoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set cell value
|
// Set cell value
|
||||||
$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
|
$sheet->getCell($columnLetter . $currentRow)->setValue($rowDatum);
|
||||||
}
|
}
|
||||||
++$columnLetter;
|
++$columnLetter;
|
||||||
}
|
}
|
||||||
++$currentRow;
|
++$currentRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
fclose($fileHandle);
|
fclose($fileHandle);
|
||||||
|
|
||||||
if ($this->_contiguous) {
|
if ($this->_contiguous) {
|
||||||
$this->_contiguousRow = $currentRow;
|
$this->_contiguousRow = $currentRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
ini_set('auto_detect_line_endings', $lineEnding);
|
ini_set('auto_detect_line_endings', $lineEnding);
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objPHPExcel;
|
return $objPHPExcel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get delimiter
|
* Get delimiter
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDelimiter() {
|
public function getDelimiter() {
|
||||||
return $this->_delimiter;
|
return $this->_delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set delimiter
|
* Set delimiter
|
||||||
*
|
*
|
||||||
* @param string $pValue Delimiter, defaults to ,
|
* @param string $pValue Delimiter, defaults to ,
|
||||||
* @return PHPExcel_Reader_CSV
|
* @return PHPExcel_Reader_CSV
|
||||||
*/
|
*/
|
||||||
public function setDelimiter($pValue = ',') {
|
public function setDelimiter($pValue = ',') {
|
||||||
$this->_delimiter = $pValue;
|
$this->_delimiter = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get enclosure
|
* Get enclosure
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getEnclosure() {
|
public function getEnclosure() {
|
||||||
return $this->_enclosure;
|
return $this->_enclosure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set enclosure
|
* Set enclosure
|
||||||
*
|
*
|
||||||
* @param string $pValue Enclosure, defaults to "
|
* @param string $pValue Enclosure, defaults to "
|
||||||
* @return PHPExcel_Reader_CSV
|
* @return PHPExcel_Reader_CSV
|
||||||
*/
|
*/
|
||||||
public function setEnclosure($pValue = '"') {
|
public function setEnclosure($pValue = '"') {
|
||||||
if ($pValue == '') {
|
if ($pValue == '') {
|
||||||
$pValue = '"';
|
$pValue = '"';
|
||||||
}
|
}
|
||||||
$this->_enclosure = $pValue;
|
$this->_enclosure = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get sheet index
|
* Get sheet index
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getSheetIndex() {
|
public function getSheetIndex() {
|
||||||
return $this->_sheetIndex;
|
return $this->_sheetIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set sheet index
|
* Set sheet index
|
||||||
*
|
*
|
||||||
* @param integer $pValue Sheet index
|
* @param integer $pValue Sheet index
|
||||||
* @return PHPExcel_Reader_CSV
|
* @return PHPExcel_Reader_CSV
|
||||||
*/
|
*/
|
||||||
public function setSheetIndex($pValue = 0) {
|
public function setSheetIndex($pValue = 0) {
|
||||||
$this->_sheetIndex = $pValue;
|
$this->_sheetIndex = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Contiguous
|
* Set Contiguous
|
||||||
*
|
*
|
||||||
* @param boolean $contiguous
|
* @param boolean $contiguous
|
||||||
*/
|
*/
|
||||||
public function setContiguous($contiguous = FALSE)
|
public function setContiguous($contiguous = FALSE)
|
||||||
{
|
{
|
||||||
$this->_contiguous = (bool) $contiguous;
|
$this->_contiguous = (bool) $contiguous;
|
||||||
if (!$contiguous) {
|
if (!$contiguous) {
|
||||||
$this->_contiguousRow = -1;
|
$this->_contiguousRow = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Contiguous
|
* Get Contiguous
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getContiguous() {
|
public function getContiguous() {
|
||||||
return $this->_contiguous;
|
return $this->_contiguous;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,18 +21,18 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel root directory */
|
/** PHPExcel root directory */
|
||||||
if (!defined('PHPEXCEL_ROOT')) {
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,15 +44,15 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
|
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Should this cell be read?
|
* Should this cell be read?
|
||||||
*
|
*
|
||||||
* @param $column String column index
|
* @param $column String column index
|
||||||
* @param $row Row index
|
* @param $row Row index
|
||||||
* @param $worksheetName Optional worksheet name
|
* @param $worksheetName Optional worksheet name
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function readCell($column, $row, $worksheetName = '') {
|
public function readCell($column, $row, $worksheetName = '') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -21,8 +21,8 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -33,20 +33,22 @@
|
|||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Reader_Exception extends PHPExcel_Exception {
|
class PHPExcel_Reader_Exception extends PHPExcel_Exception
|
||||||
/**
|
{
|
||||||
* Error handler callback
|
/**
|
||||||
*
|
* Error handler callback
|
||||||
* @param mixed $code
|
*
|
||||||
* @param mixed $string
|
* @param mixed $code
|
||||||
* @param mixed $file
|
* @param mixed $string
|
||||||
* @param mixed $line
|
* @param mixed $file
|
||||||
* @param mixed $context
|
* @param mixed $line
|
||||||
*/
|
* @param mixed $context
|
||||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
*/
|
||||||
$e = new self($string, $code);
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
$e->line = $line;
|
{
|
||||||
$e->file = $file;
|
$e = new self($string, $code);
|
||||||
throw $e;
|
$e->line = $line;
|
||||||
}
|
$e->file = $file;
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
/** PHPExcel root directory */
|
/** PHPExcel root directory */
|
||||||
@ -67,38 +67,38 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
'h1' => array('font' => array('bold' => true,
|
'h1' => array('font' => array('bold' => true,
|
||||||
'size' => 24,
|
'size' => 24,
|
||||||
),
|
),
|
||||||
), // Bold, 24pt
|
), // Bold, 24pt
|
||||||
'h2' => array('font' => array('bold' => true,
|
'h2' => array('font' => array('bold' => true,
|
||||||
'size' => 18,
|
'size' => 18,
|
||||||
),
|
),
|
||||||
), // Bold, 18pt
|
), // Bold, 18pt
|
||||||
'h3' => array('font' => array('bold' => true,
|
'h3' => array('font' => array('bold' => true,
|
||||||
'size' => 13.5,
|
'size' => 13.5,
|
||||||
),
|
),
|
||||||
), // Bold, 13.5pt
|
), // Bold, 13.5pt
|
||||||
'h4' => array('font' => array('bold' => true,
|
'h4' => array('font' => array('bold' => true,
|
||||||
'size' => 12,
|
'size' => 12,
|
||||||
),
|
),
|
||||||
), // Bold, 12pt
|
), // Bold, 12pt
|
||||||
'h5' => array('font' => array('bold' => true,
|
'h5' => array('font' => array('bold' => true,
|
||||||
'size' => 10,
|
'size' => 10,
|
||||||
),
|
),
|
||||||
), // Bold, 10pt
|
), // Bold, 10pt
|
||||||
'h6' => array('font' => array('bold' => true,
|
'h6' => array('font' => array('bold' => true,
|
||||||
'size' => 7.5,
|
'size' => 7.5,
|
||||||
),
|
),
|
||||||
), // Bold, 7.5pt
|
), // Bold, 7.5pt
|
||||||
'a' => array('font' => array('underline' => true,
|
'a' => array('font' => array('underline' => true,
|
||||||
'color' => array('argb' => PHPExcel_Style_Color::COLOR_BLUE,
|
'color' => array('argb' => PHPExcel_Style_Color::COLOR_BLUE,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), // Blue underlined
|
), // Blue underlined
|
||||||
'hr' => array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN,
|
'hr' => array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN,
|
||||||
'color' => array(\PHPExcel_Style_Color::COLOR_BLACK,
|
'color' => array(\PHPExcel_Style_Color::COLOR_BLACK,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
), // Bottom border
|
), // Bottom border
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $rowspan = array();
|
protected $rowspan = array();
|
||||||
@ -118,7 +118,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
*/
|
*/
|
||||||
protected function _isValidFormat()
|
protected function _isValidFormat()
|
||||||
{
|
{
|
||||||
// Reading 2048 bytes should be enough to validate that the format is HTML
|
// Reading 2048 bytes should be enough to validate that the format is HTML
|
||||||
$data = fread($this->_fileHandle, 2048);
|
$data = fread($this->_fileHandle, 2048);
|
||||||
if ((strpos($data, '<') !== FALSE) &&
|
if ((strpos($data, '<') !== FALSE) &&
|
||||||
(strlen($data) !== strlen(strip_tags($data)))) {
|
(strlen($data) !== strlen(strip_tags($data)))) {
|
||||||
@ -166,7 +166,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
return $this->_inputEncoding;
|
return $this->_inputEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data Array used for testing only, should write to PHPExcel object on completion of tests
|
// Data Array used for testing only, should write to PHPExcel object on completion of tests
|
||||||
protected $_dataArray = array();
|
protected $_dataArray = array();
|
||||||
protected $_tableLevel = 0;
|
protected $_tableLevel = 0;
|
||||||
protected $_nestedColumn = array('A');
|
protected $_nestedColumn = array('A');
|
||||||
@ -196,18 +196,18 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
protected function _flushCell($sheet, $column, $row, &$cellContent)
|
protected function _flushCell($sheet, $column, $row, &$cellContent)
|
||||||
{
|
{
|
||||||
if (is_string($cellContent)) {
|
if (is_string($cellContent)) {
|
||||||
// Simple String content
|
// Simple String content
|
||||||
if (trim($cellContent) > '') {
|
if (trim($cellContent) > '') {
|
||||||
// Only actually write it if there's content in the string
|
// Only actually write it if there's content in the string
|
||||||
// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
|
// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
|
||||||
// Write to worksheet to be done here...
|
// Write to worksheet to be done here...
|
||||||
// ... we return the cell so we can mess about with styles more easily
|
// ... we return the cell so we can mess about with styles more easily
|
||||||
$sheet->setCellValue($column . $row, $cellContent, true);
|
$sheet->setCellValue($column . $row, $cellContent, true);
|
||||||
$this->_dataArray[$row][$column] = $cellContent;
|
$this->_dataArray[$row][$column] = $cellContent;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// We have a Rich Text run
|
// We have a Rich Text run
|
||||||
// TODO
|
// TODO
|
||||||
$this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
|
$this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
|
||||||
}
|
}
|
||||||
$cellContent = (string) '';
|
$cellContent = (string) '';
|
||||||
@ -219,18 +219,18 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
if ($child instanceof DOMText) {
|
if ($child instanceof DOMText) {
|
||||||
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue));
|
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue));
|
||||||
if (is_string($cellContent)) {
|
if (is_string($cellContent)) {
|
||||||
// simply append the text if the cell content is a plain text string
|
// simply append the text if the cell content is a plain text string
|
||||||
$cellContent .= $domText;
|
$cellContent .= $domText;
|
||||||
} else {
|
} else {
|
||||||
// but if we have a rich text run instead, we need to append it correctly
|
// but if we have a rich text run instead, we need to append it correctly
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
} elseif ($child instanceof DOMElement) {
|
} elseif ($child instanceof DOMElement) {
|
||||||
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
|
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
|
||||||
|
|
||||||
$attributeArray = array();
|
$attributeArray = array();
|
||||||
foreach ($child->attributes as $attribute) {
|
foreach ($child->attributes as $attribute) {
|
||||||
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
|
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
|
||||||
$attributeArray[$attribute->name] = $attribute->value;
|
$attributeArray[$attribute->name] = $attribute->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,8 +239,8 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
foreach ($attributeArray as $attributeName => $attributeValue) {
|
foreach ($attributeArray as $attributeName => $attributeValue) {
|
||||||
switch ($attributeName) {
|
switch ($attributeName) {
|
||||||
case 'content':
|
case 'content':
|
||||||
// TODO
|
// TODO
|
||||||
// Extract character set, so we can convert to UTF-8 if required
|
// Extract character set, so we can convert to UTF-8 if required
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -258,13 +258,13 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
case 'em' :
|
case 'em' :
|
||||||
case 'strong':
|
case 'strong':
|
||||||
case 'b' :
|
case 'b' :
|
||||||
// echo 'STYLING, SPAN OR DIV<br />';
|
// echo 'STYLING, SPAN OR DIV<br />';
|
||||||
if ($cellContent > '')
|
if ($cellContent > '')
|
||||||
$cellContent .= ' ';
|
$cellContent .= ' ';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
if ($cellContent > '')
|
if ($cellContent > '')
|
||||||
$cellContent .= ' ';
|
$cellContent .= ' ';
|
||||||
// echo 'END OF STYLING, SPAN OR DIV<br />';
|
// echo 'END OF STYLING, SPAN OR DIV<br />';
|
||||||
break;
|
break;
|
||||||
case 'hr' :
|
case 'hr' :
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->_flushCell($sheet, $column, $row, $cellContent);
|
||||||
@ -278,21 +278,21 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
++$row;
|
++$row;
|
||||||
case 'br' :
|
case 'br' :
|
||||||
if ($this->_tableLevel > 0) {
|
if ($this->_tableLevel > 0) {
|
||||||
// If we're inside a table, replace with a \n
|
// If we're inside a table, replace with a \n
|
||||||
$cellContent .= "\n";
|
$cellContent .= "\n";
|
||||||
} else {
|
} else {
|
||||||
// Otherwise flush our existing content and move the row cursor on
|
// Otherwise flush our existing content and move the row cursor on
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->_flushCell($sheet, $column, $row, $cellContent);
|
||||||
++$row;
|
++$row;
|
||||||
}
|
}
|
||||||
// echo 'HARD LINE BREAK: ' , '<br />';
|
// echo 'HARD LINE BREAK: ' , '<br />';
|
||||||
break;
|
break;
|
||||||
case 'a' :
|
case 'a' :
|
||||||
// echo 'START OF HYPERLINK: ' , '<br />';
|
// echo 'START OF HYPERLINK: ' , '<br />';
|
||||||
foreach ($attributeArray as $attributeName => $attributeValue) {
|
foreach ($attributeArray as $attributeName => $attributeValue) {
|
||||||
switch ($attributeName) {
|
switch ($attributeName) {
|
||||||
case 'href':
|
case 'href':
|
||||||
// echo 'Link to ' , $attributeValue , '<br />';
|
// echo 'Link to ' , $attributeValue , '<br />';
|
||||||
$sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue);
|
$sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue);
|
||||||
if (isset($this->_formats[$child->nodeName])) {
|
if (isset($this->_formats[$child->nodeName])) {
|
||||||
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
|
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
|
||||||
@ -302,7 +302,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
}
|
}
|
||||||
$cellContent .= ' ';
|
$cellContent .= ' ';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF HYPERLINK:' , '<br />';
|
// echo 'END OF HYPERLINK:' , '<br />';
|
||||||
break;
|
break;
|
||||||
case 'h1' :
|
case 'h1' :
|
||||||
case 'h2' :
|
case 'h2' :
|
||||||
@ -314,19 +314,19 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
case 'ul' :
|
case 'ul' :
|
||||||
case 'p' :
|
case 'p' :
|
||||||
if ($this->_tableLevel > 0) {
|
if ($this->_tableLevel > 0) {
|
||||||
// If we're inside a table, replace with a \n
|
// If we're inside a table, replace with a \n
|
||||||
$cellContent .= "\n";
|
$cellContent .= "\n";
|
||||||
// echo 'LIST ENTRY: ' , '<br />';
|
// echo 'LIST ENTRY: ' , '<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF LIST ENTRY:' , '<br />';
|
// echo 'END OF LIST ENTRY:' , '<br />';
|
||||||
} else {
|
} else {
|
||||||
if ($cellContent > '') {
|
if ($cellContent > '') {
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->_flushCell($sheet, $column, $row, $cellContent);
|
||||||
$row++;
|
$row++;
|
||||||
}
|
}
|
||||||
// echo 'START OF PARAGRAPH: ' , '<br />';
|
// echo 'START OF PARAGRAPH: ' , '<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF PARAGRAPH:' , '<br />';
|
// echo 'END OF PARAGRAPH:' , '<br />';
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->_flushCell($sheet, $column, $row, $cellContent);
|
||||||
|
|
||||||
if (isset($this->_formats[$child->nodeName])) {
|
if (isset($this->_formats[$child->nodeName])) {
|
||||||
@ -339,19 +339,19 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
break;
|
break;
|
||||||
case 'li' :
|
case 'li' :
|
||||||
if ($this->_tableLevel > 0) {
|
if ($this->_tableLevel > 0) {
|
||||||
// If we're inside a table, replace with a \n
|
// If we're inside a table, replace with a \n
|
||||||
$cellContent .= "\n";
|
$cellContent .= "\n";
|
||||||
// echo 'LIST ENTRY: ' , '<br />';
|
// echo 'LIST ENTRY: ' , '<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF LIST ENTRY:' , '<br />';
|
// echo 'END OF LIST ENTRY:' , '<br />';
|
||||||
} else {
|
} else {
|
||||||
if ($cellContent > '') {
|
if ($cellContent > '') {
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->_flushCell($sheet, $column, $row, $cellContent);
|
||||||
}
|
}
|
||||||
++$row;
|
++$row;
|
||||||
// echo 'LIST ENTRY: ' , '<br />';
|
// echo 'LIST ENTRY: ' , '<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF LIST ENTRY:' , '<br />';
|
// echo 'END OF LIST ENTRY:' , '<br />';
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->_flushCell($sheet, $column, $row, $cellContent);
|
||||||
$column = 'A';
|
$column = 'A';
|
||||||
}
|
}
|
||||||
@ -359,11 +359,11 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
case 'table' :
|
case 'table' :
|
||||||
$this->_flushCell($sheet, $column, $row, $cellContent);
|
$this->_flushCell($sheet, $column, $row, $cellContent);
|
||||||
$column = $this->_setTableStartColumn($column);
|
$column = $this->_setTableStartColumn($column);
|
||||||
// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
|
// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
|
||||||
if ($this->_tableLevel > 1)
|
if ($this->_tableLevel > 1)
|
||||||
--$row;
|
--$row;
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
|
// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
|
||||||
$column = $this->_releaseTableStartColumn();
|
$column = $this->_releaseTableStartColumn();
|
||||||
if ($this->_tableLevel > 1) {
|
if ($this->_tableLevel > 1) {
|
||||||
++$column;
|
++$column;
|
||||||
@ -378,16 +378,16 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
case 'tr' :
|
case 'tr' :
|
||||||
$column = $this->_getTableStartColumn();
|
$column = $this->_getTableStartColumn();
|
||||||
$cellContent = '';
|
$cellContent = '';
|
||||||
// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
|
// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
++$row;
|
++$row;
|
||||||
// echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />';
|
// echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />';
|
||||||
break;
|
break;
|
||||||
case 'th' :
|
case 'th' :
|
||||||
case 'td' :
|
case 'td' :
|
||||||
// echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />';
|
// echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />';
|
||||||
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
|
||||||
// echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />';
|
// echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />';
|
||||||
|
|
||||||
while (isset($this->rowspan[$column . $row])) {
|
while (isset($this->rowspan[$column . $row])) {
|
||||||
++$column;
|
++$column;
|
||||||
@ -463,7 +463,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
fclose($this->_fileHandle);
|
fclose($this->_fileHandle);
|
||||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
|
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
|
||||||
}
|
}
|
||||||
// Close after validating
|
// Close after validating
|
||||||
fclose($this->_fileHandle);
|
fclose($this->_fileHandle);
|
||||||
|
|
||||||
// Create new PHPExcel
|
// Create new PHPExcel
|
||||||
@ -472,15 +472,15 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
}
|
}
|
||||||
$objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
|
$objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
|
||||||
|
|
||||||
// Create a new DOM object
|
// Create a new DOM object
|
||||||
$dom = new domDocument;
|
$dom = new domDocument;
|
||||||
// Reload the HTML file into the DOM object
|
// Reload the HTML file into the DOM object
|
||||||
$loaded = $dom->loadHTML($this->securityScanFile($pFilename));
|
$loaded = $dom->loadHTML($this->securityScanFile($pFilename));
|
||||||
if ($loaded === FALSE) {
|
if ($loaded === FALSE) {
|
||||||
throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
|
throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discard white space
|
// Discard white space
|
||||||
$dom->preserveWhiteSpace = false;
|
$dom->preserveWhiteSpace = false;
|
||||||
|
|
||||||
$row = 0;
|
$row = 0;
|
||||||
@ -488,7 +488,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
$content = '';
|
$content = '';
|
||||||
$this->_processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
|
$this->_processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objPHPExcel;
|
return $objPHPExcel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,14 +515,14 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
|
||||||
*
|
*
|
||||||
* @param string $xml
|
* @param string $xml
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function securityScan($xml)
|
public function securityScan($xml)
|
||||||
{
|
{
|
||||||
$pattern = '/\\0?' . implode('\\0?', str_split('<!ENTITY')) . '\\0?/';
|
$pattern = '/\\0?' . implode('\\0?', str_split('<!ENTITY')) . '\\0?/';
|
||||||
if (preg_match($pattern, $xml)) {
|
if (preg_match($pattern, $xml)) {
|
||||||
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Reader_IReadFilter
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,27 +22,18 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Reader_IReadFilter
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Reader
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
interface PHPExcel_Reader_IReadFilter
|
interface PHPExcel_Reader_IReadFilter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Should this cell be read?
|
* Should this cell be read?
|
||||||
*
|
*
|
||||||
* @param $column String column index
|
* @param $column String column index
|
||||||
* @param $row Row index
|
* @param $row Row index
|
||||||
* @param $worksheetName Optional worksheet name
|
* @param $worksheetName Optional worksheet name
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function readCell($column, $row, $worksheetName = '');
|
public function readCell($column, $row, $worksheetName = '');
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,20 +35,20 @@
|
|||||||
*/
|
*/
|
||||||
interface PHPExcel_Reader_IReader
|
interface PHPExcel_Reader_IReader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Can the current PHPExcel_Reader_IReader read the file?
|
* Can the current PHPExcel_Reader_IReader read the file?
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function canRead($pFilename);
|
public function canRead($pFilename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file
|
* Loads PHPExcel from file
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function load($pFilename);
|
public function load($pFilename);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -21,18 +21,18 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Reader
|
* @package PHPExcel_Reader
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/** PHPExcel root directory */
|
/** PHPExcel root directory */
|
||||||
if (!defined('PHPEXCEL_ROOT')) {
|
if (!defined('PHPEXCEL_ROOT')) {
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
|
||||||
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,407 +44,407 @@ if (!defined('PHPEXCEL_ROOT')) {
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Input encoding
|
* Input encoding
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_inputEncoding = 'ANSI';
|
private $_inputEncoding = 'ANSI';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sheet index to read
|
* Sheet index to read
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_sheetIndex = 0;
|
private $_sheetIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats
|
* Formats
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_formats = array();
|
private $_formats = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format Count
|
* Format Count
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_format = 0;
|
private $_format = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Reader_SYLK
|
* Create a new PHPExcel_Reader_SYLK
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that the current file is a SYLK file
|
* Validate that the current file is a SYLK file
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function _isValidFormat()
|
protected function _isValidFormat()
|
||||||
{
|
{
|
||||||
// Read sample data (first 2 KB will do)
|
// Read sample data (first 2 KB will do)
|
||||||
$data = fread($this->_fileHandle, 2048);
|
$data = fread($this->_fileHandle, 2048);
|
||||||
|
|
||||||
// Count delimiters in file
|
// Count delimiters in file
|
||||||
$delimiterCount = substr_count($data, ';');
|
$delimiterCount = substr_count($data, ';');
|
||||||
if ($delimiterCount < 1) {
|
if ($delimiterCount < 1) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Analyze first line looking for ID; signature
|
// Analyze first line looking for ID; signature
|
||||||
$lines = explode("\n", $data);
|
$lines = explode("\n", $data);
|
||||||
if (substr($lines[0],0,4) != 'ID;P') {
|
if (substr($lines[0],0,4) != 'ID;P') {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set input encoding
|
* Set input encoding
|
||||||
*
|
*
|
||||||
* @param string $pValue Input encoding
|
* @param string $pValue Input encoding
|
||||||
*/
|
*/
|
||||||
public function setInputEncoding($pValue = 'ANSI')
|
public function setInputEncoding($pValue = 'ANSI')
|
||||||
{
|
{
|
||||||
$this->_inputEncoding = $pValue;
|
$this->_inputEncoding = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get input encoding
|
* Get input encoding
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getInputEncoding()
|
public function getInputEncoding()
|
||||||
{
|
{
|
||||||
return $this->_inputEncoding;
|
return $this->_inputEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
* Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns)
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function listWorksheetInfo($pFilename)
|
public function listWorksheetInfo($pFilename)
|
||||||
{
|
{
|
||||||
// Open file
|
// Open file
|
||||||
$this->_openFile($pFilename);
|
$this->_openFile($pFilename);
|
||||||
if (!$this->_isValidFormat()) {
|
if (!$this->_isValidFormat()) {
|
||||||
fclose ($this->_fileHandle);
|
fclose ($this->_fileHandle);
|
||||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||||
}
|
}
|
||||||
$fileHandle = $this->_fileHandle;
|
$fileHandle = $this->_fileHandle;
|
||||||
rewind($fileHandle);
|
rewind($fileHandle);
|
||||||
|
|
||||||
$worksheetInfo = array();
|
$worksheetInfo = array();
|
||||||
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
$worksheetInfo[0]['worksheetName'] = 'Worksheet';
|
||||||
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
$worksheetInfo[0]['lastColumnLetter'] = 'A';
|
||||||
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
$worksheetInfo[0]['lastColumnIndex'] = 0;
|
||||||
$worksheetInfo[0]['totalRows'] = 0;
|
$worksheetInfo[0]['totalRows'] = 0;
|
||||||
$worksheetInfo[0]['totalColumns'] = 0;
|
$worksheetInfo[0]['totalColumns'] = 0;
|
||||||
|
|
||||||
// Loop through file
|
// Loop through file
|
||||||
$rowData = array();
|
$rowData = array();
|
||||||
|
|
||||||
// loop through one row (line) at a time in the file
|
// loop through one row (line) at a time in the file
|
||||||
$rowIndex = 0;
|
$rowIndex = 0;
|
||||||
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
||||||
$columnIndex = 0;
|
$columnIndex = 0;
|
||||||
|
|
||||||
// convert SYLK encoded $rowData to UTF-8
|
// convert SYLK encoded $rowData to UTF-8
|
||||||
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
||||||
|
|
||||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||||
// is escaped like this (;;)
|
// is escaped like this (;;)
|
||||||
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
||||||
|
|
||||||
$dataType = array_shift($rowData);
|
$dataType = array_shift($rowData);
|
||||||
if ($dataType == 'C') {
|
if ($dataType == 'C') {
|
||||||
// Read cell value data
|
// Read cell value data
|
||||||
foreach($rowData as $rowDatum) {
|
foreach($rowData as $rowDatum) {
|
||||||
switch($rowDatum{0}) {
|
switch($rowDatum{0}) {
|
||||||
case 'C' :
|
case 'C' :
|
||||||
case 'X' :
|
case 'X' :
|
||||||
$columnIndex = substr($rowDatum,1) - 1;
|
$columnIndex = substr($rowDatum,1) - 1;
|
||||||
break;
|
break;
|
||||||
case 'R' :
|
case 'R' :
|
||||||
case 'Y' :
|
case 'Y' :
|
||||||
$rowIndex = substr($rowDatum,1);
|
$rowIndex = substr($rowDatum,1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
|
$worksheetInfo[0]['totalRows'] = max($worksheetInfo[0]['totalRows'], $rowIndex);
|
||||||
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
|
$worksheetInfo[0]['lastColumnIndex'] = max($worksheetInfo[0]['lastColumnIndex'], $columnIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
$worksheetInfo[0]['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($worksheetInfo[0]['lastColumnIndex']);
|
||||||
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
$worksheetInfo[0]['totalColumns'] = $worksheetInfo[0]['lastColumnIndex'] + 1;
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
fclose($fileHandle);
|
fclose($fileHandle);
|
||||||
|
|
||||||
return $worksheetInfo;
|
return $worksheetInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file
|
* Loads PHPExcel from file
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function load($pFilename)
|
public function load($pFilename)
|
||||||
{
|
{
|
||||||
// Create new PHPExcel
|
// Create new PHPExcel
|
||||||
$objPHPExcel = new PHPExcel();
|
$objPHPExcel = new PHPExcel();
|
||||||
|
|
||||||
// Load into this instance
|
// Load into this instance
|
||||||
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
return $this->loadIntoExisting($pFilename, $objPHPExcel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads PHPExcel from file into PHPExcel instance
|
* Loads PHPExcel from file into PHPExcel instance
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @param PHPExcel $objPHPExcel
|
* @param PHPExcel $objPHPExcel
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Reader_Exception
|
* @throws PHPExcel_Reader_Exception
|
||||||
*/
|
*/
|
||||||
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
|
||||||
{
|
{
|
||||||
// Open file
|
// Open file
|
||||||
$this->_openFile($pFilename);
|
$this->_openFile($pFilename);
|
||||||
if (!$this->_isValidFormat()) {
|
if (!$this->_isValidFormat()) {
|
||||||
fclose ($this->_fileHandle);
|
fclose ($this->_fileHandle);
|
||||||
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid Spreadsheet file.");
|
||||||
}
|
}
|
||||||
$fileHandle = $this->_fileHandle;
|
$fileHandle = $this->_fileHandle;
|
||||||
rewind($fileHandle);
|
rewind($fileHandle);
|
||||||
|
|
||||||
// Create new PHPExcel
|
// Create new PHPExcel
|
||||||
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
|
||||||
$objPHPExcel->createSheet();
|
$objPHPExcel->createSheet();
|
||||||
}
|
}
|
||||||
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
|
$objPHPExcel->setActiveSheetIndex( $this->_sheetIndex );
|
||||||
|
|
||||||
$fromFormats = array('\-', '\ ');
|
$fromFormats = array('\-', '\ ');
|
||||||
$toFormats = array('-', ' ');
|
$toFormats = array('-', ' ');
|
||||||
|
|
||||||
// Loop through file
|
// Loop through file
|
||||||
$rowData = array();
|
$rowData = array();
|
||||||
$column = $row = '';
|
$column = $row = '';
|
||||||
|
|
||||||
// loop through one row (line) at a time in the file
|
// loop through one row (line) at a time in the file
|
||||||
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
while (($rowData = fgets($fileHandle)) !== FALSE) {
|
||||||
|
|
||||||
// convert SYLK encoded $rowData to UTF-8
|
// convert SYLK encoded $rowData to UTF-8
|
||||||
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
$rowData = PHPExcel_Shared_String::SYLKtoUTF8($rowData);
|
||||||
|
|
||||||
// explode each row at semicolons while taking into account that literal semicolon (;)
|
// explode each row at semicolons while taking into account that literal semicolon (;)
|
||||||
// is escaped like this (;;)
|
// is escaped like this (;;)
|
||||||
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
$rowData = explode("\t",str_replace('¤',';',str_replace(';',"\t",str_replace(';;','¤',rtrim($rowData)))));
|
||||||
|
|
||||||
$dataType = array_shift($rowData);
|
$dataType = array_shift($rowData);
|
||||||
// Read shared styles
|
// Read shared styles
|
||||||
if ($dataType == 'P') {
|
if ($dataType == 'P') {
|
||||||
$formatArray = array();
|
$formatArray = array();
|
||||||
foreach($rowData as $rowDatum) {
|
foreach($rowData as $rowDatum) {
|
||||||
switch($rowDatum{0}) {
|
switch($rowDatum{0}) {
|
||||||
case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1));
|
case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1));
|
||||||
break;
|
break;
|
||||||
case 'E' :
|
case 'E' :
|
||||||
case 'F' : $formatArray['font']['name'] = substr($rowDatum,1);
|
case 'F' : $formatArray['font']['name'] = substr($rowDatum,1);
|
||||||
break;
|
break;
|
||||||
case 'L' : $formatArray['font']['size'] = substr($rowDatum,1);
|
case 'L' : $formatArray['font']['size'] = substr($rowDatum,1);
|
||||||
break;
|
break;
|
||||||
case 'S' : $styleSettings = substr($rowDatum,1);
|
case 'S' : $styleSettings = substr($rowDatum,1);
|
||||||
for ($i=0;$i<strlen($styleSettings);++$i) {
|
for ($i=0;$i<strlen($styleSettings);++$i) {
|
||||||
switch ($styleSettings{$i}) {
|
switch ($styleSettings{$i}) {
|
||||||
case 'I' : $formatArray['font']['italic'] = true;
|
case 'I' : $formatArray['font']['italic'] = true;
|
||||||
break;
|
break;
|
||||||
case 'D' : $formatArray['font']['bold'] = true;
|
case 'D' : $formatArray['font']['bold'] = true;
|
||||||
break;
|
break;
|
||||||
case 'T' : $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
case 'T' : $formatArray['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||||
break;
|
break;
|
||||||
case 'B' : $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
case 'B' : $formatArray['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||||
break;
|
break;
|
||||||
case 'L' : $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
case 'L' : $formatArray['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||||
break;
|
break;
|
||||||
case 'R' : $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
case 'R' : $formatArray['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->_formats['P'.$this->_format++] = $formatArray;
|
$this->_formats['P'.$this->_format++] = $formatArray;
|
||||||
// Read cell value data
|
// Read cell value data
|
||||||
} elseif ($dataType == 'C') {
|
} elseif ($dataType == 'C') {
|
||||||
$hasCalculatedValue = false;
|
$hasCalculatedValue = false;
|
||||||
$cellData = $cellDataFormula = '';
|
$cellData = $cellDataFormula = '';
|
||||||
foreach($rowData as $rowDatum) {
|
foreach($rowData as $rowDatum) {
|
||||||
switch($rowDatum{0}) {
|
switch($rowDatum{0}) {
|
||||||
case 'C' :
|
case 'C' :
|
||||||
case 'X' : $column = substr($rowDatum,1);
|
case 'X' : $column = substr($rowDatum,1);
|
||||||
break;
|
break;
|
||||||
case 'R' :
|
case 'R' :
|
||||||
case 'Y' : $row = substr($rowDatum,1);
|
case 'Y' : $row = substr($rowDatum,1);
|
||||||
break;
|
break;
|
||||||
case 'K' : $cellData = substr($rowDatum,1);
|
case 'K' : $cellData = substr($rowDatum,1);
|
||||||
break;
|
break;
|
||||||
case 'E' : $cellDataFormula = '='.substr($rowDatum,1);
|
case 'E' : $cellDataFormula = '='.substr($rowDatum,1);
|
||||||
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
// Convert R1C1 style references to A1 style references (but only when not quoted)
|
||||||
$temp = explode('"',$cellDataFormula);
|
$temp = explode('"',$cellDataFormula);
|
||||||
$key = false;
|
$key = false;
|
||||||
foreach($temp as &$value) {
|
foreach($temp as &$value) {
|
||||||
// Only count/replace in alternate array entries
|
// Only count/replace in alternate array entries
|
||||||
if ($key = !$key) {
|
if ($key = !$key) {
|
||||||
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
|
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
|
||||||
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
|
||||||
// through the formula from left to right. Reversing means that we work right to left.through
|
// through the formula from left to right. Reversing means that we work right to left.through
|
||||||
// the formula
|
// the formula
|
||||||
$cellReferences = array_reverse($cellReferences);
|
$cellReferences = array_reverse($cellReferences);
|
||||||
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
|
||||||
// then modify the formula to use that new reference
|
// then modify the formula to use that new reference
|
||||||
foreach($cellReferences as $cellReference) {
|
foreach($cellReferences as $cellReference) {
|
||||||
$rowReference = $cellReference[2][0];
|
$rowReference = $cellReference[2][0];
|
||||||
// Empty R reference is the current row
|
// Empty R reference is the current row
|
||||||
if ($rowReference == '') $rowReference = $row;
|
if ($rowReference == '') $rowReference = $row;
|
||||||
// Bracketed R references are relative to the current row
|
// Bracketed R references are relative to the current row
|
||||||
if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]');
|
if ($rowReference{0} == '[') $rowReference = $row + trim($rowReference,'[]');
|
||||||
$columnReference = $cellReference[4][0];
|
$columnReference = $cellReference[4][0];
|
||||||
// Empty C reference is the current column
|
// Empty C reference is the current column
|
||||||
if ($columnReference == '') $columnReference = $column;
|
if ($columnReference == '') $columnReference = $column;
|
||||||
// Bracketed C references are relative to the current column
|
// Bracketed C references are relative to the current column
|
||||||
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
|
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
|
||||||
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
|
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
|
||||||
|
|
||||||
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
|
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($value);
|
unset($value);
|
||||||
// Then rebuild the formula string
|
// Then rebuild the formula string
|
||||||
$cellDataFormula = implode('"',$temp);
|
$cellDataFormula = implode('"',$temp);
|
||||||
$hasCalculatedValue = true;
|
$hasCalculatedValue = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||||
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
||||||
|
|
||||||
// Set cell value
|
// Set cell value
|
||||||
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
|
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setValue(($hasCalculatedValue) ? $cellDataFormula : $cellData);
|
||||||
if ($hasCalculatedValue) {
|
if ($hasCalculatedValue) {
|
||||||
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
$cellData = PHPExcel_Calculation::_unwrapResult($cellData);
|
||||||
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
|
$objPHPExcel->getActiveSheet()->getCell($columnLetter.$row)->setCalculatedValue($cellData);
|
||||||
}
|
}
|
||||||
// Read cell formatting
|
// Read cell formatting
|
||||||
} elseif ($dataType == 'F') {
|
} elseif ($dataType == 'F') {
|
||||||
$formatStyle = $columnWidth = $styleSettings = '';
|
$formatStyle = $columnWidth = $styleSettings = '';
|
||||||
$styleData = array();
|
$styleData = array();
|
||||||
foreach($rowData as $rowDatum) {
|
foreach($rowData as $rowDatum) {
|
||||||
switch($rowDatum{0}) {
|
switch($rowDatum{0}) {
|
||||||
case 'C' :
|
case 'C' :
|
||||||
case 'X' : $column = substr($rowDatum,1);
|
case 'X' : $column = substr($rowDatum,1);
|
||||||
break;
|
break;
|
||||||
case 'R' :
|
case 'R' :
|
||||||
case 'Y' : $row = substr($rowDatum,1);
|
case 'Y' : $row = substr($rowDatum,1);
|
||||||
break;
|
break;
|
||||||
case 'P' : $formatStyle = $rowDatum;
|
case 'P' : $formatStyle = $rowDatum;
|
||||||
break;
|
break;
|
||||||
case 'W' : list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1));
|
case 'W' : list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1));
|
||||||
break;
|
break;
|
||||||
case 'S' : $styleSettings = substr($rowDatum,1);
|
case 'S' : $styleSettings = substr($rowDatum,1);
|
||||||
for ($i=0;$i<strlen($styleSettings);++$i) {
|
for ($i=0;$i<strlen($styleSettings);++$i) {
|
||||||
switch ($styleSettings{$i}) {
|
switch ($styleSettings{$i}) {
|
||||||
case 'I' : $styleData['font']['italic'] = true;
|
case 'I' : $styleData['font']['italic'] = true;
|
||||||
break;
|
break;
|
||||||
case 'D' : $styleData['font']['bold'] = true;
|
case 'D' : $styleData['font']['bold'] = true;
|
||||||
break;
|
break;
|
||||||
case 'T' : $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
case 'T' : $styleData['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||||
break;
|
break;
|
||||||
case 'B' : $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
case 'B' : $styleData['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||||
break;
|
break;
|
||||||
case 'L' : $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
case 'L' : $styleData['borders']['left']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||||
break;
|
break;
|
||||||
case 'R' : $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
case 'R' : $styleData['borders']['right']['style'] = PHPExcel_Style_Border::BORDER_THIN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (($formatStyle > '') && ($column > '') && ($row > '')) {
|
if (($formatStyle > '') && ($column > '') && ($row > '')) {
|
||||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||||
if (isset($this->_formats[$formatStyle])) {
|
if (isset($this->_formats[$formatStyle])) {
|
||||||
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]);
|
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($this->_formats[$formatStyle]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((!empty($styleData)) && ($column > '') && ($row > '')) {
|
if ((!empty($styleData)) && ($column > '') && ($row > '')) {
|
||||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($column-1);
|
||||||
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
|
$objPHPExcel->getActiveSheet()->getStyle($columnLetter.$row)->applyFromArray($styleData);
|
||||||
}
|
}
|
||||||
if ($columnWidth > '') {
|
if ($columnWidth > '') {
|
||||||
if ($startCol == $endCol) {
|
if ($startCol == $endCol) {
|
||||||
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
||||||
} else {
|
} else {
|
||||||
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
$startCol = PHPExcel_Cell::stringFromColumnIndex($startCol-1);
|
||||||
$endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1);
|
$endCol = PHPExcel_Cell::stringFromColumnIndex($endCol-1);
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
$objPHPExcel->getActiveSheet()->getColumnDimension($startCol)->setWidth($columnWidth);
|
||||||
do {
|
do {
|
||||||
$objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
|
$objPHPExcel->getActiveSheet()->getColumnDimension(++$startCol)->setWidth($columnWidth);
|
||||||
} while ($startCol != $endCol);
|
} while ($startCol != $endCol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach($rowData as $rowDatum) {
|
foreach($rowData as $rowDatum) {
|
||||||
switch($rowDatum{0}) {
|
switch($rowDatum{0}) {
|
||||||
case 'C' :
|
case 'C' :
|
||||||
case 'X' : $column = substr($rowDatum,1);
|
case 'X' : $column = substr($rowDatum,1);
|
||||||
break;
|
break;
|
||||||
case 'R' :
|
case 'R' :
|
||||||
case 'Y' : $row = substr($rowDatum,1);
|
case 'Y' : $row = substr($rowDatum,1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
fclose($fileHandle);
|
fclose($fileHandle);
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objPHPExcel;
|
return $objPHPExcel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get sheet index
|
* Get sheet index
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getSheetIndex() {
|
public function getSheetIndex() {
|
||||||
return $this->_sheetIndex;
|
return $this->_sheetIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set sheet index
|
* Set sheet index
|
||||||
*
|
*
|
||||||
* @param int $pValue Sheet index
|
* @param int $pValue Sheet index
|
||||||
* @return PHPExcel_Reader_SYLK
|
* @return PHPExcel_Reader_SYLK
|
||||||
*/
|
*/
|
||||||
public function setSheetIndex($pValue = 0) {
|
public function setSheetIndex($pValue = 0) {
|
||||||
$this->_sheetIndex = $pValue;
|
$this->_sheetIndex = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Worksheet
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -24,15 +25,6 @@
|
|||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Worksheet
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Worksheet
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Worksheet implements PHPExcel_IComparable
|
class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||||
{
|
{
|
||||||
/* Break types */
|
/* Break types */
|
||||||
@ -332,7 +324,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*/
|
*/
|
||||||
private $_codeName = null;
|
private $_codeName = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new worksheet
|
* Create a new worksheet
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pParent
|
* @param PHPExcel $pParent
|
||||||
@ -344,7 +336,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$this->_parent = $pParent;
|
$this->_parent = $pParent;
|
||||||
$this->setTitle($pTitle, FALSE);
|
$this->setTitle($pTitle, FALSE);
|
||||||
// setTitle can change $pTitle
|
// setTitle can change $pTitle
|
||||||
$this->setCodeName($this->getTitle());
|
$this->setCodeName($this->getTitle());
|
||||||
$this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE);
|
$this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE);
|
||||||
|
|
||||||
$this->_cellCollection = PHPExcel_CachedObjectStorageFactory::getInstance($this);
|
$this->_cellCollection = PHPExcel_CachedObjectStorageFactory::getInstance($this);
|
||||||
@ -385,11 +377,11 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* typically so that the worksheet object can be unset
|
* typically so that the worksheet object can be unset
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function disconnectCells() {
|
public function disconnectCells() {
|
||||||
if ( $this->_cellCollection !== NULL){
|
if ( $this->_cellCollection !== NULL){
|
||||||
$this->_cellCollection->unsetWorksheetCells();
|
$this->_cellCollection->unsetWorksheetCells();
|
||||||
$this->_cellCollection = NULL;
|
$this->_cellCollection = NULL;
|
||||||
}
|
}
|
||||||
// detach ourself from the workbook, so that it can then delete this worksheet successfully
|
// detach ourself from the workbook, so that it can then delete this worksheet successfully
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
}
|
}
|
||||||
@ -398,19 +390,19 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* Code to execute when this worksheet is unset()
|
* Code to execute when this worksheet is unset()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
PHPExcel_Calculation::getInstance($this->_parent)
|
PHPExcel_Calculation::getInstance($this->_parent)
|
||||||
->clearCalculationCacheForWorksheet($this->_title);
|
->clearCalculationCacheForWorksheet($this->_title);
|
||||||
|
|
||||||
$this->disconnectCells();
|
$this->disconnectCells();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the cache controller for the cell collection
|
* Return the cache controller for the cell collection
|
||||||
*
|
*
|
||||||
* @return PHPExcel_CachedObjectStorage_xxx
|
* @return PHPExcel_CachedObjectStorage_xxx
|
||||||
*/
|
*/
|
||||||
public function getCellCacheController() {
|
public function getCellCacheController() {
|
||||||
return $this->_cellCollection;
|
return $this->_cellCollection;
|
||||||
} // function getCellCacheController()
|
} // function getCellCacheController()
|
||||||
|
|
||||||
@ -745,22 +737,22 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// loop through all cells in the worksheet
|
// loop through all cells in the worksheet
|
||||||
foreach ($this->getCellCollection(false) as $cellID) {
|
foreach ($this->getCellCollection(false) as $cellID) {
|
||||||
$cell = $this->getCell($cellID);
|
$cell = $this->getCell($cellID);
|
||||||
if (isset($autoSizes[$this->_cellCollection->getCurrentColumn()])) {
|
if (isset($autoSizes[$this->_cellCollection->getCurrentColumn()])) {
|
||||||
// Determine width if cell does not participate in a merge
|
// Determine width if cell does not participate in a merge
|
||||||
if (!isset($isMergeCell[$this->_cellCollection->getCurrentAddress()])) {
|
if (!isset($isMergeCell[$this->_cellCollection->getCurrentAddress()])) {
|
||||||
// Calculated value
|
// Calculated value
|
||||||
// To formatted string
|
// To formatted string
|
||||||
$cellValue = PHPExcel_Style_NumberFormat::toFormattedString(
|
$cellValue = PHPExcel_Style_NumberFormat::toFormattedString(
|
||||||
$cell->getCalculatedValue(),
|
$cell->getCalculatedValue(),
|
||||||
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode()
|
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode()
|
||||||
);
|
);
|
||||||
|
|
||||||
$autoSizes[$this->_cellCollection->getCurrentColumn()] = max(
|
$autoSizes[$this->_cellCollection->getCurrentColumn()] = max(
|
||||||
(float) $autoSizes[$this->_cellCollection->getCurrentColumn()],
|
(float) $autoSizes[$this->_cellCollection->getCurrentColumn()],
|
||||||
(float)PHPExcel_Shared_Font::calculateColumnWidth(
|
(float)PHPExcel_Shared_Font::calculateColumnWidth(
|
||||||
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
|
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont(),
|
||||||
$cellValue,
|
$cellValue,
|
||||||
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
|
$this->getParent()->getCellXfByIndex($cell->getXfIndex())->getAlignment()->getTextRotation(),
|
||||||
$this->getDefaultStyle()->getFont()
|
$this->getDefaultStyle()->getFont()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -783,7 +775,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
*/
|
*/
|
||||||
public function getParent() {
|
public function getParent() {
|
||||||
return $this->_parent;
|
return $this->_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -793,7 +785,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param PHPExcel $parent
|
* @param PHPExcel $parent
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function rebindParent(PHPExcel $parent) {
|
public function rebindParent(PHPExcel $parent) {
|
||||||
if ($this->_parent !== null) {
|
if ($this->_parent !== null) {
|
||||||
$namedRanges = $this->_parent->getNamedRanges();
|
$namedRanges = $this->_parent->getNamedRanges();
|
||||||
foreach ($namedRanges as $namedRange) {
|
foreach ($namedRanges as $namedRange) {
|
||||||
@ -824,7 +816,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @param string $pValue String containing the dimension of this worksheet
|
* @param string $pValue String containing the dimension of this worksheet
|
||||||
* @param string $updateFormulaCellReferences boolean Flag indicating whether cell references in formulae should
|
* @param string $updateFormulaCellReferences boolean Flag indicating whether cell references in formulae should
|
||||||
* be updated to reflect the new sheet name.
|
* be updated to reflect the new sheet name.
|
||||||
* This should be left as the default true, unless you are
|
* This should be left as the default true, unless you are
|
||||||
* certain that no formula cells on any worksheet contain
|
* certain that no formula cells on any worksheet contain
|
||||||
* references to this worksheet
|
* references to this worksheet
|
||||||
@ -845,14 +837,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
|
|
||||||
if ($this->_parent) {
|
if ($this->_parent) {
|
||||||
// Is there already such sheet name?
|
// Is there already such sheet name?
|
||||||
if ($this->_parent->sheetNameExists($pValue)) {
|
if ($this->_parent->sheetNameExists($pValue)) {
|
||||||
// Use name, but append with lowest possible integer
|
// Use name, but append with lowest possible integer
|
||||||
|
|
||||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
|
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
|
||||||
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
|
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
|
||||||
}
|
}
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($this->_parent->sheetNameExists($pValue . ' ' . $i)) {
|
while ($this->_parent->sheetNameExists($pValue . ' ' . $i)) {
|
||||||
++$i;
|
++$i;
|
||||||
if ($i == 10) {
|
if ($i == 10) {
|
||||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
|
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
|
||||||
@ -877,10 +869,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
if ($this->_parent) {
|
if ($this->_parent) {
|
||||||
// New title
|
// New title
|
||||||
$newTitle = $this->getTitle();
|
$newTitle = $this->getTitle();
|
||||||
PHPExcel_Calculation::getInstance($this->_parent)
|
PHPExcel_Calculation::getInstance($this->_parent)
|
||||||
->renameCalculationCacheForWorksheet($oldTitle, $newTitle);
|
->renameCalculationCacheForWorksheet($oldTitle, $newTitle);
|
||||||
if ($updateFormulaCellReferences)
|
if ($updateFormulaCellReferences)
|
||||||
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle);
|
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -891,7 +883,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return string Sheet state (visible, hidden, veryHidden)
|
* @return string Sheet state (visible, hidden, veryHidden)
|
||||||
*/
|
*/
|
||||||
public function getSheetState() {
|
public function getSheetState() {
|
||||||
return $this->_sheetState;
|
return $this->_sheetState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -901,7 +893,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param string $value Sheet state (visible, hidden, veryHidden)
|
* @param string $value Sheet state (visible, hidden, veryHidden)
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) {
|
public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) {
|
||||||
$this->_sheetState = $value;
|
$this->_sheetState = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -1160,7 +1152,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// Worksheet reference?
|
// Worksheet reference?
|
||||||
if (strpos($pCoordinate, '!') !== false) {
|
if (strpos($pCoordinate, '!') !== false) {
|
||||||
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
|
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
|
||||||
return $this->_parent->getSheetByName($worksheetReference[0])->getCell(strtoupper($worksheetReference[1]));
|
return $this->_parent->getSheetByName($worksheetReference[0])->getCell(strtoupper($worksheetReference[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Named range?
|
// Named range?
|
||||||
@ -1202,7 +1194,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
return $this->_cellCollection->getCacheData($coordinate);
|
return $this->_cellCollection->getCacheData($coordinate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_createNewCell($coordinate);
|
return $this->_createNewCell($coordinate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1211,16 +1203,16 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param string $pCoordinate Coordinate of the cell
|
* @param string $pCoordinate Coordinate of the cell
|
||||||
* @return PHPExcel_Cell Cell that was created
|
* @return PHPExcel_Cell Cell that was created
|
||||||
*/
|
*/
|
||||||
private function _createNewCell($pCoordinate)
|
private function _createNewCell($pCoordinate)
|
||||||
{
|
{
|
||||||
$cell = $this->_cellCollection->addCacheData(
|
$cell = $this->_cellCollection->addCacheData(
|
||||||
$pCoordinate,
|
$pCoordinate,
|
||||||
new PHPExcel_Cell(
|
new PHPExcel_Cell(
|
||||||
NULL,
|
NULL,
|
||||||
PHPExcel_Cell_DataType::TYPE_NULL,
|
PHPExcel_Cell_DataType::TYPE_NULL,
|
||||||
$this
|
$this
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->_cellCollectionIsSorted = false;
|
$this->_cellCollectionIsSorted = false;
|
||||||
|
|
||||||
// Coordinates
|
// Coordinates
|
||||||
@ -1230,7 +1222,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]);
|
$this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]);
|
||||||
|
|
||||||
// Cell needs appropriate xfIndex from dimensions records
|
// Cell needs appropriate xfIndex from dimensions records
|
||||||
// but don't create dimension records if they don't already exist
|
// but don't create dimension records if they don't already exist
|
||||||
$rowDimension = $this->getRowDimension($aCoordinates[1], FALSE);
|
$rowDimension = $this->getRowDimension($aCoordinates[1], FALSE);
|
||||||
$columnDimension = $this->getColumnDimension($aCoordinates[0], FALSE);
|
$columnDimension = $this->getColumnDimension($aCoordinates[0], FALSE);
|
||||||
|
|
||||||
@ -1243,8 +1235,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $cell;
|
return $cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the cell at a specific coordinate exist?
|
* Does the cell at a specific coordinate exist?
|
||||||
*
|
*
|
||||||
@ -1257,7 +1249,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// Worksheet reference?
|
// Worksheet reference?
|
||||||
if (strpos($pCoordinate, '!') !== false) {
|
if (strpos($pCoordinate, '!') !== false) {
|
||||||
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
|
$worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
|
||||||
return $this->_parent->getSheetByName($worksheetReference[0])->cellExists(strtoupper($worksheetReference[1]));
|
return $this->_parent->getSheetByName($worksheetReference[0])->cellExists(strtoupper($worksheetReference[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Named range?
|
// Named range?
|
||||||
@ -1318,8 +1310,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
|
|
||||||
// Get row dimension
|
// Get row dimension
|
||||||
if (!isset($this->_rowDimensions[$pRow])) {
|
if (!isset($this->_rowDimensions[$pRow])) {
|
||||||
if (!$create)
|
if (!$create)
|
||||||
return NULL;
|
return NULL;
|
||||||
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
|
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
|
||||||
|
|
||||||
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
|
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
|
||||||
@ -1340,8 +1332,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
|
|
||||||
// Fetch dimensions
|
// Fetch dimensions
|
||||||
if (!isset($this->_columnDimensions[$pColumn])) {
|
if (!isset($this->_columnDimensions[$pColumn])) {
|
||||||
if (!$create)
|
if (!$create)
|
||||||
return NULL;
|
return NULL;
|
||||||
$this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn);
|
$this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn);
|
||||||
|
|
||||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn))
|
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn))
|
||||||
@ -1496,10 +1488,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null)
|
public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null)
|
||||||
{
|
{
|
||||||
if (!is_null($pColumn2) && !is_null($pRow2)) {
|
if (!is_null($pColumn2) && !is_null($pRow2)) {
|
||||||
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' .
|
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' .
|
||||||
PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
|
PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
|
||||||
return $this->getStyle($cellRange);
|
return $this->getStyle($cellRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
|
return $this->getStyle(PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow);
|
||||||
}
|
}
|
||||||
@ -1538,7 +1530,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
|
|
||||||
// Add the style to the workbook if necessary
|
// Add the style to the workbook if necessary
|
||||||
$workbook = $this->_parent;
|
$workbook = $this->_parent;
|
||||||
if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) {
|
if ($existingStyle = $this->_parent->getCellXfByHashCode($pCellStyle->getHashCode())) {
|
||||||
// there is already such cell Xf in our collection
|
// there is already such cell Xf in our collection
|
||||||
$xfIndex = $existingStyle->getIndex();
|
$xfIndex = $existingStyle->getIndex();
|
||||||
} else {
|
} else {
|
||||||
@ -1572,7 +1564,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* Please note that this will overwrite existing cell styles for cells in range!
|
* Please note that this will overwrite existing cell styles for cells in range!
|
||||||
*
|
*
|
||||||
* @param array of PHPExcel_Style_Conditional $pCellStyle Cell style to duplicate
|
* @param array of PHPExcel_Style_Conditional $pCellStyle Cell style to duplicate
|
||||||
* @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
|
* @param string $pRange Range of cells (i.e. "A1:B10"), or just one cell (i.e. "A1")
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
@ -1639,13 +1631,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$pCell = strtoupper($pCell);
|
$pCell = strtoupper($pCell);
|
||||||
|
|
||||||
if ($pCell != '') {
|
if ($pCell != '') {
|
||||||
if ($pBreak == PHPExcel_Worksheet::BREAK_NONE) {
|
if ($pBreak == PHPExcel_Worksheet::BREAK_NONE) {
|
||||||
if (isset($this->_breaks[$pCell])) {
|
if (isset($this->_breaks[$pCell])) {
|
||||||
unset($this->_breaks[$pCell]);
|
unset($this->_breaks[$pCell]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->_breaks[$pCell] = $pBreak;
|
$this->_breaks[$pCell] = $pBreak;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Exception('No cell coordinate specified.');
|
throw new PHPExcel_Exception('No cell coordinate specified.');
|
||||||
}
|
}
|
||||||
@ -2229,7 +2221,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
/**
|
/**
|
||||||
* Set comments array for the entire sheet.
|
* Set comments array for the entire sheet.
|
||||||
*
|
*
|
||||||
* @param array of PHPExcel_Comment
|
* @param array of PHPExcel_Comment
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function setComments($pValue = array())
|
public function setComments($pValue = array())
|
||||||
@ -2447,7 +2439,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* True - Return rows and columns indexed by their actual row and column IDs
|
* True - Return rows and columns indexed by their actual row and column IDs
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
|
public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
|
||||||
// Returnvalue
|
// Returnvalue
|
||||||
$returnValue = array();
|
$returnValue = array();
|
||||||
// Identify the range that we need to extract from the worksheet
|
// Identify the range that we need to extract from the worksheet
|
||||||
@ -2485,10 +2477,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
if ($formatData) {
|
if ($formatData) {
|
||||||
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
||||||
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
|
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
|
||||||
$returnValue[$rRef][$cRef],
|
$returnValue[$rRef][$cRef],
|
||||||
($style && $style->getNumberFormat()) ?
|
($style && $style->getNumberFormat()) ?
|
||||||
$style->getNumberFormat()->getFormatCode() :
|
$style->getNumberFormat()->getFormatCode() :
|
||||||
PHPExcel_Style_NumberFormat::FORMAT_GENERAL
|
PHPExcel_Style_NumberFormat::FORMAT_GENERAL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2519,14 +2511,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @return array
|
* @return array
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
|
public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
|
||||||
$namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
|
$namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
|
||||||
if ($namedRange !== NULL) {
|
if ($namedRange !== NULL) {
|
||||||
$pWorkSheet = $namedRange->getWorksheet();
|
$pWorkSheet = $namedRange->getWorksheet();
|
||||||
$pCellRange = $namedRange->getRange();
|
$pCellRange = $namedRange->getRange();
|
||||||
|
|
||||||
return $pWorkSheet->rangeToArray( $pCellRange,
|
return $pWorkSheet->rangeToArray( $pCellRange,
|
||||||
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
|
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.');
|
throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.');
|
||||||
@ -2543,7 +2535,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* True - Return rows and columns indexed by their actual row and column IDs
|
* True - Return rows and columns indexed by their actual row and column IDs
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
|
public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
|
||||||
// Garbage collect...
|
// Garbage collect...
|
||||||
$this->garbageCollect();
|
$this->garbageCollect();
|
||||||
|
|
||||||
@ -2551,8 +2543,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$maxCol = $this->getHighestColumn();
|
$maxCol = $this->getHighestColumn();
|
||||||
$maxRow = $this->getHighestRow();
|
$maxRow = $this->getHighestRow();
|
||||||
// Return
|
// Return
|
||||||
return $this->rangeToArray( 'A1:'.$maxCol.$maxRow,
|
return $this->rangeToArray( 'A1:'.$maxCol.$maxRow,
|
||||||
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
|
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2563,7 +2555,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet_RowIterator
|
* @return PHPExcel_Worksheet_RowIterator
|
||||||
*/
|
*/
|
||||||
public function getRowIterator($startRow = 1, $endRow = null) {
|
public function getRowIterator($startRow = 1, $endRow = null) {
|
||||||
return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow);
|
return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2575,7 +2567,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet_ColumnIterator
|
* @return PHPExcel_Worksheet_ColumnIterator
|
||||||
*/
|
*/
|
||||||
public function getColumnIterator($startColumn = 'A', $endColumn = null) {
|
public function getColumnIterator($startColumn = 'A', $endColumn = null) {
|
||||||
return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn);
|
return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2584,7 +2576,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function garbageCollect() {
|
public function garbageCollect() {
|
||||||
// Flush cache
|
// Flush cache
|
||||||
$this->_cellCollection->getCacheData('A1');
|
$this->_cellCollection->getCacheData('A1');
|
||||||
// Build a reference table from images
|
// Build a reference table from images
|
||||||
@ -2628,7 +2620,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return string Hash code
|
* @return string Hash code
|
||||||
*/
|
*/
|
||||||
public function getHashCode() {
|
public function getHashCode() {
|
||||||
if ($this->_dirty) {
|
if ($this->_dirty) {
|
||||||
$this->_hash = md5( $this->_title .
|
$this->_hash = md5( $this->_title .
|
||||||
$this->_autoFilter .
|
$this->_autoFilter .
|
||||||
@ -2650,7 +2642,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param bool $returnRange Return range? (see example)
|
* @param bool $returnRange Return range? (see example)
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function extractSheetTitle($pRange, $returnRange = false) {
|
public static function extractSheetTitle($pRange, $returnRange = false) {
|
||||||
// Sheet title included?
|
// Sheet title included?
|
||||||
if (($sep = strpos($pRange, '!')) === false) {
|
if (($sep = strpos($pRange, '!')) === false) {
|
||||||
return '';
|
return '';
|
||||||
@ -2782,7 +2774,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @param string $range
|
* @param string $range
|
||||||
* @return string Adjusted range value
|
* @return string Adjusted range value
|
||||||
*/
|
*/
|
||||||
public function shrinkRangeToFit($range) {
|
public function shrinkRangeToFit($range) {
|
||||||
$maxCol = $this->getHighestColumn();
|
$maxCol = $this->getHighestColumn();
|
||||||
$maxRow = $this->getHighestRow();
|
$maxRow = $this->getHighestRow();
|
||||||
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
|
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
|
||||||
@ -2844,7 +2836,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function copy() {
|
public function copy() {
|
||||||
$copied = clone $this;
|
$copied = clone $this;
|
||||||
|
|
||||||
return $copied;
|
return $copied;
|
||||||
@ -2853,7 +2845,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
/**
|
/**
|
||||||
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
* Implement PHP __clone to create a deep clone, not just a shallow copy.
|
||||||
*/
|
*/
|
||||||
public function __clone() {
|
public function __clone() {
|
||||||
foreach ($this as $key => $val) {
|
foreach ($this as $key => $val) {
|
||||||
if ($key == '_parent') {
|
if ($key == '_parent') {
|
||||||
continue;
|
continue;
|
||||||
@ -2878,68 +2870,68 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Define the code name of the sheet
|
* Define the code name of the sheet
|
||||||
*
|
*
|
||||||
* @param null|string Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore)
|
* @param null|string Same rule as Title minus space not allowed (but, like Excel, change silently space to underscore)
|
||||||
* @return objWorksheet
|
* @return objWorksheet
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function setCodeName($pValue=null){
|
public function setCodeName($pValue=null){
|
||||||
// Is this a 'rename' or not?
|
// Is this a 'rename' or not?
|
||||||
if ($this->getCodeName() == $pValue) {
|
if ($this->getCodeName() == $pValue) {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
$pValue = str_replace(' ', '_', $pValue);//Excel does this automatically without flinching, we are doing the same
|
$pValue = str_replace(' ', '_', $pValue);//Excel does this automatically without flinching, we are doing the same
|
||||||
// Syntax check
|
// Syntax check
|
||||||
// throw an exception if not valid
|
// throw an exception if not valid
|
||||||
self::_checkSheetCodeName($pValue);
|
self::_checkSheetCodeName($pValue);
|
||||||
|
|
||||||
// We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_'
|
// We use the same code that setTitle to find a valid codeName else not using a space (Excel don't like) but a '_'
|
||||||
|
|
||||||
if ($this->getParent()) {
|
if ($this->getParent()) {
|
||||||
// Is there already such sheet name?
|
// Is there already such sheet name?
|
||||||
if ($this->getParent()->sheetCodeNameExists($pValue)) {
|
if ($this->getParent()->sheetCodeNameExists($pValue)) {
|
||||||
// Use name, but append with lowest possible integer
|
// Use name, but append with lowest possible integer
|
||||||
|
|
||||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
|
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
|
||||||
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
|
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
|
||||||
}
|
}
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
|
while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
|
||||||
++$i;
|
++$i;
|
||||||
if ($i == 10) {
|
if ($i == 10) {
|
||||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
|
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
|
||||||
$pValue = PHPExcel_Shared_String::Substring($pValue,0,28);
|
$pValue = PHPExcel_Shared_String::Substring($pValue,0,28);
|
||||||
}
|
}
|
||||||
} elseif ($i == 100) {
|
} elseif ($i == 100) {
|
||||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
|
if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
|
||||||
$pValue = PHPExcel_Shared_String::Substring($pValue,0,27);
|
$pValue = PHPExcel_Shared_String::Substring($pValue,0,27);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pValue = $pValue . '_' . $i;// ok, we have a valid name
|
$pValue = $pValue . '_' . $i;// ok, we have a valid name
|
||||||
//codeName is'nt used in formula : no need to call for an update
|
//codeName is'nt used in formula : no need to call for an update
|
||||||
//return $this->setTitle($altTitle,$updateFormulaCellReferences);
|
//return $this->setTitle($altTitle,$updateFormulaCellReferences);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_codeName=$pValue;
|
$this->_codeName=$pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Return the code name of the sheet
|
* Return the code name of the sheet
|
||||||
*
|
*
|
||||||
* @return null|string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
public function getCodeName(){
|
public function getCodeName(){
|
||||||
return $this->_codeName;
|
return $this->_codeName;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sheet has a code name ?
|
* Sheet has a code name ?
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function hasCodeName(){
|
public function hasCodeName(){
|
||||||
return !(is_null($this->_codeName));
|
return !(is_null($this->_codeName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_Abstract
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,138 +22,130 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer
|
* @package PHPExcel_Writer
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_Abstract
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write charts that are defined in the workbook?
|
* Write charts that are defined in the workbook?
|
||||||
* Identifies whether the Writer should write definitions for any charts that exist in the PHPExcel object;
|
* Identifies whether the Writer should write definitions for any charts that exist in the PHPExcel object;
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $_includeCharts = FALSE;
|
protected $_includeCharts = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pre-calculate formulas
|
* Pre-calculate formulas
|
||||||
* Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
|
* Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
|
||||||
* immediately available to MS Excel or other office spreadsheet viewer when opening the file
|
* immediately available to MS Excel or other office spreadsheet viewer when opening the file
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $_preCalculateFormulas = TRUE;
|
protected $_preCalculateFormulas = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use disk caching where possible?
|
* Use disk caching where possible?
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $_useDiskCaching = FALSE;
|
protected $_useDiskCaching = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disk caching directory
|
* Disk caching directory
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $_diskCachingDirectory = './';
|
protected $_diskCachingDirectory = './';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write charts in workbook?
|
* Write charts in workbook?
|
||||||
* If this is true, then the Writer will write definitions for any charts that exist in the PHPExcel object.
|
* If this is true, then the Writer will write definitions for any charts that exist in the PHPExcel object.
|
||||||
* If false (the default) it will ignore any charts defined in the PHPExcel object.
|
* If false (the default) it will ignore any charts defined in the PHPExcel object.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getIncludeCharts() {
|
public function getIncludeCharts() {
|
||||||
return $this->_includeCharts;
|
return $this->_includeCharts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set write charts in workbook
|
* Set write charts in workbook
|
||||||
* Set to true, to advise the Writer to include any charts that exist in the PHPExcel object.
|
* Set to true, to advise the Writer to include any charts that exist in the PHPExcel object.
|
||||||
* Set to false (the default) to ignore charts.
|
* Set to false (the default) to ignore charts.
|
||||||
*
|
*
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
* @return PHPExcel_Writer_IWriter
|
* @return PHPExcel_Writer_IWriter
|
||||||
*/
|
*/
|
||||||
public function setIncludeCharts($pValue = FALSE) {
|
public function setIncludeCharts($pValue = false)
|
||||||
$this->_includeCharts = (boolean) $pValue;
|
{
|
||||||
return $this;
|
$this->_includeCharts = (boolean) $pValue;
|
||||||
}
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Pre-Calculate Formulas flag
|
* Get Pre-Calculate Formulas flag
|
||||||
* If this is true (the default), then the writer will recalculate all formulae in a workbook when saving,
|
* If this is true (the default), then the writer will recalculate all formulae in a workbook when saving,
|
||||||
* so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet
|
* so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet
|
||||||
* viewer when opening the file
|
* viewer when opening the file
|
||||||
* If false, then formulae are not calculated on save. This is faster for saving in PHPExcel, but slower
|
* If false, then formulae are not calculated on save. This is faster for saving in PHPExcel, but slower
|
||||||
* when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself
|
* when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getPreCalculateFormulas() {
|
public function getPreCalculateFormulas() {
|
||||||
return $this->_preCalculateFormulas;
|
return $this->_preCalculateFormulas;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Pre-Calculate Formulas
|
* Set Pre-Calculate Formulas
|
||||||
* Set to true (the default) to advise the Writer to calculate all formulae on save
|
* Set to true (the default) to advise the Writer to calculate all formulae on save
|
||||||
* Set to false to prevent precalculation of formulae on save.
|
* Set to false to prevent precalculation of formulae on save.
|
||||||
*
|
*
|
||||||
* @param boolean $pValue Pre-Calculate Formulas?
|
* @param boolean $pValue Pre-Calculate Formulas?
|
||||||
* @return PHPExcel_Writer_IWriter
|
* @return PHPExcel_Writer_IWriter
|
||||||
*/
|
*/
|
||||||
public function setPreCalculateFormulas($pValue = TRUE) {
|
public function setPreCalculateFormulas($pValue = TRUE) {
|
||||||
$this->_preCalculateFormulas = (boolean) $pValue;
|
$this->_preCalculateFormulas = (boolean) $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get use disk caching where possible?
|
* Get use disk caching where possible?
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getUseDiskCaching() {
|
public function getUseDiskCaching() {
|
||||||
return $this->_useDiskCaching;
|
return $this->_useDiskCaching;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set use disk caching where possible?
|
* Set use disk caching where possible?
|
||||||
*
|
*
|
||||||
* @param boolean $pValue
|
* @param boolean $pValue
|
||||||
* @param string $pDirectory Disk caching directory
|
* @param string $pDirectory Disk caching directory
|
||||||
* @throws PHPExcel_Writer_Exception when directory does not exist
|
* @throws PHPExcel_Writer_Exception when directory does not exist
|
||||||
* @return PHPExcel_Writer_Excel2007
|
* @return PHPExcel_Writer_Excel2007
|
||||||
*/
|
*/
|
||||||
public function setUseDiskCaching($pValue = FALSE, $pDirectory = NULL) {
|
public function setUseDiskCaching($pValue = FALSE, $pDirectory = NULL) {
|
||||||
$this->_useDiskCaching = $pValue;
|
$this->_useDiskCaching = $pValue;
|
||||||
|
|
||||||
if ($pDirectory !== NULL) {
|
if ($pDirectory !== NULL) {
|
||||||
if (is_dir($pDirectory)) {
|
if (is_dir($pDirectory)) {
|
||||||
$this->_diskCachingDirectory = $pDirectory;
|
$this->_diskCachingDirectory = $pDirectory;
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("Directory does not exist: $pDirectory");
|
throw new PHPExcel_Writer_Exception("Directory does not exist: $pDirectory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get disk caching directory
|
* Get disk caching directory
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDiskCachingDirectory() {
|
public function getDiskCachingDirectory() {
|
||||||
return $this->_diskCachingDirectory;
|
return $this->_diskCachingDirectory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_CSV
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -19,292 +20,286 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_CSV
|
* @package PHPExcel_Writer_CSV
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* PHPExcel object
|
||||||
|
*
|
||||||
|
* @var PHPExcel
|
||||||
|
*/
|
||||||
|
private $_phpExcel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delimiter
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_delimiter = ',';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Writer_CSV
|
* Enclosure
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @var string
|
||||||
* @package PHPExcel_Writer_CSV
|
*/
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
private $_enclosure = '"';
|
||||||
*/
|
|
||||||
class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter {
|
|
||||||
/**
|
|
||||||
* PHPExcel object
|
|
||||||
*
|
|
||||||
* @var PHPExcel
|
|
||||||
*/
|
|
||||||
private $_phpExcel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delimiter
|
* Line ending
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_delimiter = ',';
|
private $_lineEnding = PHP_EOL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enclosure
|
* Sheet index to write
|
||||||
*
|
*
|
||||||
* @var string
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_enclosure = '"';
|
private $_sheetIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Line ending
|
* Whether to write a BOM (for UTF8).
|
||||||
*
|
*
|
||||||
* @var string
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_lineEnding = PHP_EOL;
|
private $_useBOM = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sheet index to write
|
* Whether to write a fully Excel compatible CSV file.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_sheetIndex = 0;
|
private $_excelCompatibility = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to write a BOM (for UTF8).
|
* Create a new PHPExcel_Writer_CSV
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @param PHPExcel $phpExcel PHPExcel object
|
||||||
*/
|
*/
|
||||||
private $_useBOM = false;
|
public function __construct(PHPExcel $phpExcel)
|
||||||
|
{
|
||||||
|
$this->_phpExcel = $phpExcel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to write a fully Excel compatible CSV file.
|
* Save PHPExcel to file
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @param string $pFilename
|
||||||
*/
|
* @throws PHPExcel_Writer_Exception
|
||||||
private $_excelCompatibility = false;
|
*/
|
||||||
|
public function save($pFilename = null)
|
||||||
|
{
|
||||||
|
// Fetch sheet
|
||||||
|
$sheet = $this->_phpExcel->getSheet($this->_sheetIndex);
|
||||||
|
|
||||||
/**
|
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
|
||||||
* Create a new PHPExcel_Writer_CSV
|
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
|
||||||
*
|
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
|
||||||
* @param PHPExcel $phpExcel PHPExcel object
|
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
|
||||||
*/
|
|
||||||
public function __construct(PHPExcel $phpExcel) {
|
|
||||||
$this->_phpExcel = $phpExcel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// Open file
|
||||||
* Save PHPExcel to file
|
$fileHandle = fopen($pFilename, 'wb+');
|
||||||
*
|
if ($fileHandle === false) {
|
||||||
* @param string $pFilename
|
throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing.");
|
||||||
* @throws PHPExcel_Writer_Exception
|
}
|
||||||
*/
|
|
||||||
public function save($pFilename = null) {
|
|
||||||
// Fetch sheet
|
|
||||||
$sheet = $this->_phpExcel->getSheet($this->_sheetIndex);
|
|
||||||
|
|
||||||
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
|
if ($this->_excelCompatibility) {
|
||||||
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
|
fwrite($fileHandle, "\xEF\xBB\xBF"); // Enforce UTF-8 BOM Header
|
||||||
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
|
$this->setEnclosure('"'); // Set enclosure to "
|
||||||
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
|
$this->setDelimiter(";"); // Set delimiter to a semi-colon
|
||||||
|
|
||||||
// Open file
|
|
||||||
$fileHandle = fopen($pFilename, 'wb+');
|
|
||||||
if ($fileHandle === false) {
|
|
||||||
throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->_excelCompatibility) {
|
|
||||||
fwrite($fileHandle, "\xEF\xBB\xBF"); // Enforce UTF-8 BOM Header
|
|
||||||
$this->setEnclosure('"'); // Set enclosure to "
|
|
||||||
$this->setDelimiter(";"); // Set delimiter to a semi-colon
|
|
||||||
$this->setLineEnding("\r\n");
|
$this->setLineEnding("\r\n");
|
||||||
fwrite($fileHandle, 'sep=' . $this->getDelimiter() . $this->_lineEnding);
|
fwrite($fileHandle, 'sep=' . $this->getDelimiter() . $this->_lineEnding);
|
||||||
} elseif ($this->_useBOM) {
|
} elseif ($this->_useBOM) {
|
||||||
// Write the UTF-8 BOM code if required
|
// Write the UTF-8 BOM code if required
|
||||||
fwrite($fileHandle, "\xEF\xBB\xBF");
|
fwrite($fileHandle, "\xEF\xBB\xBF");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identify the range that we need to extract from the worksheet
|
// Identify the range that we need to extract from the worksheet
|
||||||
$maxCol = $sheet->getHighestDataColumn();
|
$maxCol = $sheet->getHighestDataColumn();
|
||||||
$maxRow = $sheet->getHighestDataRow();
|
$maxRow = $sheet->getHighestDataRow();
|
||||||
|
|
||||||
// Write rows to file
|
// Write rows to file
|
||||||
for($row = 1; $row <= $maxRow; ++$row) {
|
for($row = 1; $row <= $maxRow; ++$row) {
|
||||||
// Convert the row to an array...
|
// Convert the row to an array...
|
||||||
$cellsArray = $sheet->rangeToArray('A'.$row.':'.$maxCol.$row,'', $this->_preCalculateFormulas);
|
$cellsArray = $sheet->rangeToArray('A'.$row.':'.$maxCol.$row,'', $this->_preCalculateFormulas);
|
||||||
// ... and write to the file
|
// ... and write to the file
|
||||||
$this->_writeLine($fileHandle, $cellsArray[0]);
|
$this->_writeLine($fileHandle, $cellsArray[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
fclose($fileHandle);
|
fclose($fileHandle);
|
||||||
|
|
||||||
PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
|
PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
|
||||||
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get delimiter
|
* Get delimiter
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getDelimiter() {
|
public function getDelimiter() {
|
||||||
return $this->_delimiter;
|
return $this->_delimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set delimiter
|
* Set delimiter
|
||||||
*
|
*
|
||||||
* @param string $pValue Delimiter, defaults to ,
|
* @param string $pValue Delimiter, defaults to ,
|
||||||
* @return PHPExcel_Writer_CSV
|
* @return PHPExcel_Writer_CSV
|
||||||
*/
|
*/
|
||||||
public function setDelimiter($pValue = ',') {
|
public function setDelimiter($pValue = ',') {
|
||||||
$this->_delimiter = $pValue;
|
$this->_delimiter = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get enclosure
|
* Get enclosure
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getEnclosure() {
|
public function getEnclosure() {
|
||||||
return $this->_enclosure;
|
return $this->_enclosure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set enclosure
|
* Set enclosure
|
||||||
*
|
*
|
||||||
* @param string $pValue Enclosure, defaults to "
|
* @param string $pValue Enclosure, defaults to "
|
||||||
* @return PHPExcel_Writer_CSV
|
* @return PHPExcel_Writer_CSV
|
||||||
*/
|
*/
|
||||||
public function setEnclosure($pValue = '"') {
|
public function setEnclosure($pValue = '"') {
|
||||||
if ($pValue == '') {
|
if ($pValue == '') {
|
||||||
$pValue = null;
|
$pValue = null;
|
||||||
}
|
}
|
||||||
$this->_enclosure = $pValue;
|
$this->_enclosure = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get line ending
|
* Get line ending
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getLineEnding() {
|
public function getLineEnding() {
|
||||||
return $this->_lineEnding;
|
return $this->_lineEnding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set line ending
|
* Set line ending
|
||||||
*
|
*
|
||||||
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
|
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
|
||||||
* @return PHPExcel_Writer_CSV
|
* @return PHPExcel_Writer_CSV
|
||||||
*/
|
*/
|
||||||
public function setLineEnding($pValue = PHP_EOL) {
|
public function setLineEnding($pValue = PHP_EOL) {
|
||||||
$this->_lineEnding = $pValue;
|
$this->_lineEnding = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether BOM should be used
|
* Get whether BOM should be used
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getUseBOM() {
|
public function getUseBOM() {
|
||||||
return $this->_useBOM;
|
return $this->_useBOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether BOM should be used
|
* Set whether BOM should be used
|
||||||
*
|
*
|
||||||
* @param boolean $pValue Use UTF-8 byte-order mark? Defaults to false
|
* @param boolean $pValue Use UTF-8 byte-order mark? Defaults to false
|
||||||
* @return PHPExcel_Writer_CSV
|
* @return PHPExcel_Writer_CSV
|
||||||
*/
|
*/
|
||||||
public function setUseBOM($pValue = false) {
|
public function setUseBOM($pValue = false) {
|
||||||
$this->_useBOM = $pValue;
|
$this->_useBOM = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get whether the file should be saved with full Excel Compatibility
|
* Get whether the file should be saved with full Excel Compatibility
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getExcelCompatibility() {
|
public function getExcelCompatibility() {
|
||||||
return $this->_excelCompatibility;
|
return $this->_excelCompatibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether the file should be saved with full Excel Compatibility
|
* Set whether the file should be saved with full Excel Compatibility
|
||||||
*
|
*
|
||||||
* @param boolean $pValue Set the file to be written as a fully Excel compatible csv file
|
* @param boolean $pValue Set the file to be written as a fully Excel compatible csv file
|
||||||
* Note that this overrides other settings such as useBOM, enclosure and delimiter
|
* Note that this overrides other settings such as useBOM, enclosure and delimiter
|
||||||
* @return PHPExcel_Writer_CSV
|
* @return PHPExcel_Writer_CSV
|
||||||
*/
|
*/
|
||||||
public function setExcelCompatibility($pValue = false) {
|
public function setExcelCompatibility($pValue = false) {
|
||||||
$this->_excelCompatibility = $pValue;
|
$this->_excelCompatibility = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get sheet index
|
* Get sheet index
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getSheetIndex() {
|
public function getSheetIndex() {
|
||||||
return $this->_sheetIndex;
|
return $this->_sheetIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set sheet index
|
* Set sheet index
|
||||||
*
|
*
|
||||||
* @param int $pValue Sheet index
|
* @param int $pValue Sheet index
|
||||||
* @return PHPExcel_Writer_CSV
|
* @return PHPExcel_Writer_CSV
|
||||||
*/
|
*/
|
||||||
public function setSheetIndex($pValue = 0) {
|
public function setSheetIndex($pValue = 0) {
|
||||||
$this->_sheetIndex = $pValue;
|
$this->_sheetIndex = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write line to CSV file
|
* Write line to CSV file
|
||||||
*
|
*
|
||||||
* @param mixed $pFileHandle PHP filehandle
|
* @param mixed $pFileHandle PHP filehandle
|
||||||
* @param array $pValues Array containing values in a row
|
* @param array $pValues Array containing values in a row
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeLine($pFileHandle = null, $pValues = null) {
|
private function _writeLine($pFileHandle = null, $pValues = null) {
|
||||||
if (is_array($pValues)) {
|
if (is_array($pValues)) {
|
||||||
// No leading delimiter
|
// No leading delimiter
|
||||||
$writeDelimiter = false;
|
$writeDelimiter = false;
|
||||||
|
|
||||||
// Build the line
|
// Build the line
|
||||||
$line = '';
|
$line = '';
|
||||||
|
|
||||||
foreach ($pValues as $element) {
|
foreach ($pValues as $element) {
|
||||||
// Escape enclosures
|
// Escape enclosures
|
||||||
$element = str_replace($this->_enclosure, $this->_enclosure . $this->_enclosure, $element);
|
$element = str_replace($this->_enclosure, $this->_enclosure . $this->_enclosure, $element);
|
||||||
|
|
||||||
// Add delimiter
|
// Add delimiter
|
||||||
if ($writeDelimiter) {
|
if ($writeDelimiter) {
|
||||||
$line .= $this->_delimiter;
|
$line .= $this->_delimiter;
|
||||||
} else {
|
} else {
|
||||||
$writeDelimiter = true;
|
$writeDelimiter = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add enclosed string
|
// Add enclosed string
|
||||||
$line .= $this->_enclosure . $element . $this->_enclosure;
|
$line .= $this->_enclosure . $element . $this->_enclosure;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add line ending
|
// Add line ending
|
||||||
$line .= $this->_lineEnding;
|
$line .= $this->_lineEnding;
|
||||||
|
|
||||||
// Write to file
|
// Write to file
|
||||||
fwrite($pFileHandle, $line);
|
fwrite($pFileHandle, $line);
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("Invalid data row passed to CSV writer.");
|
throw new PHPExcel_Writer_Exception("Invalid data row passed to CSV writer.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_Excel2007
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,421 +22,412 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel2007
|
* @package PHPExcel_Writer_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_Excel2007
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer_2007
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Pre-calculate formulas
|
* Pre-calculate formulas
|
||||||
* Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
|
* Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
|
||||||
* immediately available to MS Excel or other office spreadsheet viewer when opening the file
|
* immediately available to MS Excel or other office spreadsheet viewer when opening the file
|
||||||
*
|
*
|
||||||
* Overrides the default TRUE for this specific writer for performance reasons
|
* Overrides the default TRUE for this specific writer for performance reasons
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected $_preCalculateFormulas = FALSE;
|
protected $_preCalculateFormulas = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Office2003 compatibility
|
* Office2003 compatibility
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_office2003compatibility = false;
|
private $_office2003compatibility = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private writer parts
|
* Private writer parts
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Writer_Excel2007_WriterPart[]
|
* @var PHPExcel_Writer_Excel2007_WriterPart[]
|
||||||
*/
|
*/
|
||||||
private $_writerParts = array();
|
private $_writerParts = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private PHPExcel
|
* Private PHPExcel
|
||||||
*
|
*
|
||||||
* @var PHPExcel
|
* @var PHPExcel
|
||||||
*/
|
*/
|
||||||
private $_spreadSheet;
|
private $_spreadSheet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private string table
|
* Private string table
|
||||||
*
|
*
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
private $_stringTable = array();
|
private $_stringTable = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private unique PHPExcel_Style_Conditional HashTable
|
* Private unique PHPExcel_Style_Conditional HashTable
|
||||||
*
|
*
|
||||||
* @var PHPExcel_HashTable
|
* @var PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
private $_stylesConditionalHashTable;
|
private $_stylesConditionalHashTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private unique PHPExcel_Style HashTable
|
* Private unique PHPExcel_Style HashTable
|
||||||
*
|
*
|
||||||
* @var PHPExcel_HashTable
|
* @var PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
private $_styleHashTable;
|
private $_styleHashTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private unique PHPExcel_Style_Fill HashTable
|
* Private unique PHPExcel_Style_Fill HashTable
|
||||||
*
|
*
|
||||||
* @var PHPExcel_HashTable
|
* @var PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
private $_fillHashTable;
|
private $_fillHashTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private unique PHPExcel_Style_Font HashTable
|
* Private unique PHPExcel_Style_Font HashTable
|
||||||
*
|
*
|
||||||
* @var PHPExcel_HashTable
|
* @var PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
private $_fontHashTable;
|
private $_fontHashTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private unique PHPExcel_Style_Borders HashTable
|
* Private unique PHPExcel_Style_Borders HashTable
|
||||||
*
|
*
|
||||||
* @var PHPExcel_HashTable
|
* @var PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
private $_bordersHashTable ;
|
private $_bordersHashTable ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private unique PHPExcel_Style_NumberFormat HashTable
|
* Private unique PHPExcel_Style_NumberFormat HashTable
|
||||||
*
|
*
|
||||||
* @var PHPExcel_HashTable
|
* @var PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
private $_numFmtHashTable;
|
private $_numFmtHashTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private unique PHPExcel_Worksheet_BaseDrawing HashTable
|
* Private unique PHPExcel_Worksheet_BaseDrawing HashTable
|
||||||
*
|
*
|
||||||
* @var PHPExcel_HashTable
|
* @var PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
private $_drawingHashTable;
|
private $_drawingHashTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Writer_Excel2007
|
* Create a new PHPExcel_Writer_Excel2007
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
*/
|
*/
|
||||||
public function __construct(PHPExcel $pPHPExcel = null)
|
public function __construct(PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
// Assign PHPExcel
|
// Assign PHPExcel
|
||||||
$this->setPHPExcel($pPHPExcel);
|
$this->setPHPExcel($pPHPExcel);
|
||||||
|
|
||||||
$writerPartsArray = array( 'stringtable' => 'PHPExcel_Writer_Excel2007_StringTable',
|
$writerPartsArray = array( 'stringtable' => 'PHPExcel_Writer_Excel2007_StringTable',
|
||||||
'contenttypes' => 'PHPExcel_Writer_Excel2007_ContentTypes',
|
'contenttypes' => 'PHPExcel_Writer_Excel2007_ContentTypes',
|
||||||
'docprops' => 'PHPExcel_Writer_Excel2007_DocProps',
|
'docprops' => 'PHPExcel_Writer_Excel2007_DocProps',
|
||||||
'rels' => 'PHPExcel_Writer_Excel2007_Rels',
|
'rels' => 'PHPExcel_Writer_Excel2007_Rels',
|
||||||
'theme' => 'PHPExcel_Writer_Excel2007_Theme',
|
'theme' => 'PHPExcel_Writer_Excel2007_Theme',
|
||||||
'style' => 'PHPExcel_Writer_Excel2007_Style',
|
'style' => 'PHPExcel_Writer_Excel2007_Style',
|
||||||
'workbook' => 'PHPExcel_Writer_Excel2007_Workbook',
|
'workbook' => 'PHPExcel_Writer_Excel2007_Workbook',
|
||||||
'worksheet' => 'PHPExcel_Writer_Excel2007_Worksheet',
|
'worksheet' => 'PHPExcel_Writer_Excel2007_Worksheet',
|
||||||
'drawing' => 'PHPExcel_Writer_Excel2007_Drawing',
|
'drawing' => 'PHPExcel_Writer_Excel2007_Drawing',
|
||||||
'comments' => 'PHPExcel_Writer_Excel2007_Comments',
|
'comments' => 'PHPExcel_Writer_Excel2007_Comments',
|
||||||
'chart' => 'PHPExcel_Writer_Excel2007_Chart',
|
'chart' => 'PHPExcel_Writer_Excel2007_Chart',
|
||||||
'relsvba' => 'PHPExcel_Writer_Excel2007_RelsVBA',
|
'relsvba' => 'PHPExcel_Writer_Excel2007_RelsVBA',
|
||||||
'relsribbonobjects' => 'PHPExcel_Writer_Excel2007_RelsRibbon'
|
'relsribbonobjects' => 'PHPExcel_Writer_Excel2007_RelsRibbon'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Initialise writer parts
|
// Initialise writer parts
|
||||||
// and Assign their parent IWriters
|
// and Assign their parent IWriters
|
||||||
foreach ($writerPartsArray as $writer => $class) {
|
foreach ($writerPartsArray as $writer => $class) {
|
||||||
$this->_writerParts[$writer] = new $class($this);
|
$this->_writerParts[$writer] = new $class($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
$hashTablesArray = array( '_stylesConditionalHashTable', '_fillHashTable', '_fontHashTable',
|
$hashTablesArray = array( '_stylesConditionalHashTable', '_fillHashTable', '_fontHashTable',
|
||||||
'_bordersHashTable', '_numFmtHashTable', '_drawingHashTable',
|
'_bordersHashTable', '_numFmtHashTable', '_drawingHashTable',
|
||||||
'_styleHashTable'
|
'_styleHashTable'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set HashTable variables
|
// Set HashTable variables
|
||||||
foreach ($hashTablesArray as $tableName) {
|
foreach ($hashTablesArray as $tableName) {
|
||||||
$this->$tableName = new PHPExcel_HashTable();
|
$this->$tableName = new PHPExcel_HashTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get writer part
|
* Get writer part
|
||||||
*
|
*
|
||||||
* @param string $pPartName Writer part name
|
* @param string $pPartName Writer part name
|
||||||
* @return PHPExcel_Writer_Excel2007_WriterPart
|
* @return PHPExcel_Writer_Excel2007_WriterPart
|
||||||
*/
|
*/
|
||||||
public function getWriterPart($pPartName = '') {
|
public function getWriterPart($pPartName = '') {
|
||||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||||
return $this->_writerParts[strtolower($pPartName)];
|
return $this->_writerParts[strtolower($pPartName)];
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save PHPExcel to file
|
* Save PHPExcel to file
|
||||||
*
|
*
|
||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function save($pFilename = null)
|
public function save($pFilename = null)
|
||||||
{
|
{
|
||||||
if ($this->_spreadSheet !== NULL) {
|
if ($this->_spreadSheet !== NULL) {
|
||||||
// garbage collect
|
// garbage collect
|
||||||
$this->_spreadSheet->garbageCollect();
|
$this->_spreadSheet->garbageCollect();
|
||||||
|
|
||||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||||
$originalFilename = $pFilename;
|
$originalFilename = $pFilename;
|
||||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||||
$pFilename = @tempnam(PHPExcel_Shared_File::sys_get_temp_dir(), 'phpxltmp');
|
$pFilename = @tempnam(PHPExcel_Shared_File::sys_get_temp_dir(), 'phpxltmp');
|
||||||
if ($pFilename == '') {
|
if ($pFilename == '') {
|
||||||
$pFilename = $originalFilename;
|
$pFilename = $originalFilename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->getWriteDebugLog();
|
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->getWriteDebugLog();
|
||||||
PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog(FALSE);
|
PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog(FALSE);
|
||||||
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
|
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
|
||||||
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
||||||
|
|
||||||
// Create string lookup table
|
// Create string lookup table
|
||||||
$this->_stringTable = array();
|
$this->_stringTable = array();
|
||||||
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
|
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
|
||||||
$this->_stringTable = $this->getWriterPart('StringTable')->createStringTable($this->_spreadSheet->getSheet($i), $this->_stringTable);
|
$this->_stringTable = $this->getWriterPart('StringTable')->createStringTable($this->_spreadSheet->getSheet($i), $this->_stringTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create styles dictionaries
|
// Create styles dictionaries
|
||||||
$this->_styleHashTable->addFromSource( $this->getWriterPart('Style')->allStyles($this->_spreadSheet) );
|
$this->_styleHashTable->addFromSource( $this->getWriterPart('Style')->allStyles($this->_spreadSheet) );
|
||||||
$this->_stylesConditionalHashTable->addFromSource( $this->getWriterPart('Style')->allConditionalStyles($this->_spreadSheet) );
|
$this->_stylesConditionalHashTable->addFromSource( $this->getWriterPart('Style')->allConditionalStyles($this->_spreadSheet) );
|
||||||
$this->_fillHashTable->addFromSource( $this->getWriterPart('Style')->allFills($this->_spreadSheet) );
|
$this->_fillHashTable->addFromSource( $this->getWriterPart('Style')->allFills($this->_spreadSheet) );
|
||||||
$this->_fontHashTable->addFromSource( $this->getWriterPart('Style')->allFonts($this->_spreadSheet) );
|
$this->_fontHashTable->addFromSource( $this->getWriterPart('Style')->allFonts($this->_spreadSheet) );
|
||||||
$this->_bordersHashTable->addFromSource( $this->getWriterPart('Style')->allBorders($this->_spreadSheet) );
|
$this->_bordersHashTable->addFromSource( $this->getWriterPart('Style')->allBorders($this->_spreadSheet) );
|
||||||
$this->_numFmtHashTable->addFromSource( $this->getWriterPart('Style')->allNumberFormats($this->_spreadSheet) );
|
$this->_numFmtHashTable->addFromSource( $this->getWriterPart('Style')->allNumberFormats($this->_spreadSheet) );
|
||||||
|
|
||||||
// Create drawing dictionary
|
// Create drawing dictionary
|
||||||
$this->_drawingHashTable->addFromSource( $this->getWriterPart('Drawing')->allDrawings($this->_spreadSheet) );
|
$this->_drawingHashTable->addFromSource( $this->getWriterPart('Drawing')->allDrawings($this->_spreadSheet) );
|
||||||
|
|
||||||
// Create new ZIP file and open it for writing
|
// Create new ZIP file and open it for writing
|
||||||
$zipClass = PHPExcel_Settings::getZipClass();
|
$zipClass = PHPExcel_Settings::getZipClass();
|
||||||
$objZip = new $zipClass();
|
$objZip = new $zipClass();
|
||||||
|
|
||||||
// Retrieve OVERWRITE and CREATE constants from the instantiated zip class
|
// Retrieve OVERWRITE and CREATE constants from the instantiated zip class
|
||||||
// This method of accessing constant values from a dynamic class should work with all appropriate versions of PHP
|
// This method of accessing constant values from a dynamic class should work with all appropriate versions of PHP
|
||||||
$ro = new ReflectionObject($objZip);
|
$ro = new ReflectionObject($objZip);
|
||||||
$zipOverWrite = $ro->getConstant('OVERWRITE');
|
$zipOverWrite = $ro->getConstant('OVERWRITE');
|
||||||
$zipCreate = $ro->getConstant('CREATE');
|
$zipCreate = $ro->getConstant('CREATE');
|
||||||
|
|
||||||
if (file_exists($pFilename)) {
|
if (file_exists($pFilename)) {
|
||||||
unlink($pFilename);
|
unlink($pFilename);
|
||||||
}
|
}
|
||||||
// Try opening the ZIP file
|
// Try opening the ZIP file
|
||||||
if ($objZip->open($pFilename, $zipOverWrite) !== true) {
|
if ($objZip->open($pFilename, $zipOverWrite) !== true) {
|
||||||
if ($objZip->open($pFilename, $zipCreate) !== true) {
|
if ($objZip->open($pFilename, $zipCreate) !== true) {
|
||||||
throw new PHPExcel_Writer_Exception("Could not open " . $pFilename . " for writing.");
|
throw new PHPExcel_Writer_Exception("Could not open " . $pFilename . " for writing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add [Content_Types].xml to ZIP file
|
// Add [Content_Types].xml to ZIP file
|
||||||
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_spreadSheet, $this->_includeCharts));
|
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_spreadSheet, $this->_includeCharts));
|
||||||
|
|
||||||
//if hasMacros, add the vbaProject.bin file, Certificate file(if exists)
|
//if hasMacros, add the vbaProject.bin file, Certificate file(if exists)
|
||||||
if($this->_spreadSheet->hasMacros()){
|
if($this->_spreadSheet->hasMacros()){
|
||||||
$macrosCode=$this->_spreadSheet->getMacrosCode();
|
$macrosCode=$this->_spreadSheet->getMacrosCode();
|
||||||
if(!is_null($macrosCode)){// we have the code ?
|
if(!is_null($macrosCode)){// we have the code ?
|
||||||
$objZip->addFromString('xl/vbaProject.bin', $macrosCode);//allways in 'xl', allways named vbaProject.bin
|
$objZip->addFromString('xl/vbaProject.bin', $macrosCode);//allways in 'xl', allways named vbaProject.bin
|
||||||
if($this->_spreadSheet->hasMacrosCertificate()){//signed macros ?
|
if($this->_spreadSheet->hasMacrosCertificate()){//signed macros ?
|
||||||
// Yes : add the certificate file and the related rels file
|
// Yes : add the certificate file and the related rels file
|
||||||
$objZip->addFromString('xl/vbaProjectSignature.bin', $this->_spreadSheet->getMacrosCertificate());
|
$objZip->addFromString('xl/vbaProjectSignature.bin', $this->_spreadSheet->getMacrosCertificate());
|
||||||
$objZip->addFromString('xl/_rels/vbaProject.bin.rels',
|
$objZip->addFromString('xl/_rels/vbaProject.bin.rels',
|
||||||
$this->getWriterPart('RelsVBA')->writeVBARelationships($this->_spreadSheet));
|
$this->getWriterPart('RelsVBA')->writeVBARelationships($this->_spreadSheet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels)
|
//a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels)
|
||||||
if($this->_spreadSheet->hasRibbon()){
|
if($this->_spreadSheet->hasRibbon()){
|
||||||
$tmpRibbonTarget=$this->_spreadSheet->getRibbonXMLData('target');
|
$tmpRibbonTarget=$this->_spreadSheet->getRibbonXMLData('target');
|
||||||
$objZip->addFromString($tmpRibbonTarget, $this->_spreadSheet->getRibbonXMLData('data'));
|
$objZip->addFromString($tmpRibbonTarget, $this->_spreadSheet->getRibbonXMLData('data'));
|
||||||
if($this->_spreadSheet->hasRibbonBinObjects()){
|
if($this->_spreadSheet->hasRibbonBinObjects()){
|
||||||
$tmpRootPath=dirname($tmpRibbonTarget).'/';
|
$tmpRootPath=dirname($tmpRibbonTarget).'/';
|
||||||
$ribbonBinObjects=$this->_spreadSheet->getRibbonBinObjects('data');//the files to write
|
$ribbonBinObjects=$this->_spreadSheet->getRibbonBinObjects('data');//the files to write
|
||||||
foreach($ribbonBinObjects as $aPath=>$aContent){
|
foreach($ribbonBinObjects as $aPath=>$aContent){
|
||||||
$objZip->addFromString($tmpRootPath.$aPath, $aContent);
|
$objZip->addFromString($tmpRootPath.$aPath, $aContent);
|
||||||
}
|
}
|
||||||
//the rels for files
|
//the rels for files
|
||||||
$objZip->addFromString($tmpRootPath.'_rels/'.basename($tmpRibbonTarget).'.rels',
|
$objZip->addFromString($tmpRootPath.'_rels/'.basename($tmpRibbonTarget).'.rels',
|
||||||
$this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->_spreadSheet));
|
$this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->_spreadSheet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add relationships to ZIP file
|
// Add relationships to ZIP file
|
||||||
$objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_spreadSheet));
|
$objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_spreadSheet));
|
||||||
$objZip->addFromString('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->_spreadSheet));
|
$objZip->addFromString('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->_spreadSheet));
|
||||||
|
|
||||||
// Add document properties to ZIP file
|
// Add document properties to ZIP file
|
||||||
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet));
|
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet));
|
||||||
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet));
|
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet));
|
||||||
$customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->_spreadSheet);
|
$customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->_spreadSheet);
|
||||||
if ($customPropertiesPart !== NULL) {
|
if ($customPropertiesPart !== NULL) {
|
||||||
$objZip->addFromString('docProps/custom.xml', $customPropertiesPart);
|
$objZip->addFromString('docProps/custom.xml', $customPropertiesPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add theme to ZIP file
|
// Add theme to ZIP file
|
||||||
$objZip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_spreadSheet));
|
$objZip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_spreadSheet));
|
||||||
|
|
||||||
// Add string table to ZIP file
|
// Add string table to ZIP file
|
||||||
$objZip->addFromString('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->_stringTable));
|
$objZip->addFromString('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->_stringTable));
|
||||||
|
|
||||||
// Add styles to ZIP file
|
// Add styles to ZIP file
|
||||||
$objZip->addFromString('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->_spreadSheet));
|
$objZip->addFromString('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->_spreadSheet));
|
||||||
|
|
||||||
// Add workbook to ZIP file
|
// Add workbook to ZIP file
|
||||||
$objZip->addFromString('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->_spreadSheet, $this->_preCalculateFormulas));
|
$objZip->addFromString('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->_spreadSheet, $this->_preCalculateFormulas));
|
||||||
|
|
||||||
$chartCount = 0;
|
$chartCount = 0;
|
||||||
// Add worksheets
|
// Add worksheets
|
||||||
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
|
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
|
||||||
$objZip->addFromString('xl/worksheets/sheet' . ($i + 1) . '.xml', $this->getWriterPart('Worksheet')->writeWorksheet($this->_spreadSheet->getSheet($i), $this->_stringTable, $this->_includeCharts));
|
$objZip->addFromString('xl/worksheets/sheet' . ($i + 1) . '.xml', $this->getWriterPart('Worksheet')->writeWorksheet($this->_spreadSheet->getSheet($i), $this->_stringTable, $this->_includeCharts));
|
||||||
if ($this->_includeCharts) {
|
if ($this->_includeCharts) {
|
||||||
$charts = $this->_spreadSheet->getSheet($i)->getChartCollection();
|
$charts = $this->_spreadSheet->getSheet($i)->getChartCollection();
|
||||||
if (count($charts) > 0) {
|
if (count($charts) > 0) {
|
||||||
foreach($charts as $chart) {
|
foreach($charts as $chart) {
|
||||||
$objZip->addFromString('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart));
|
$objZip->addFromString('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart));
|
||||||
$chartCount++;
|
$chartCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$chartRef1 = $chartRef2 = 0;
|
$chartRef1 = $chartRef2 = 0;
|
||||||
// Add worksheet relationships (drawings, ...)
|
// Add worksheet relationships (drawings, ...)
|
||||||
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
|
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
|
||||||
|
|
||||||
// Add relationships
|
// Add relationships
|
||||||
$objZip->addFromString('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->_spreadSheet->getSheet($i), ($i + 1), $this->_includeCharts));
|
$objZip->addFromString('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->_spreadSheet->getSheet($i), ($i + 1), $this->_includeCharts));
|
||||||
|
|
||||||
$drawings = $this->_spreadSheet->getSheet($i)->getDrawingCollection();
|
$drawings = $this->_spreadSheet->getSheet($i)->getDrawingCollection();
|
||||||
$drawingCount = count($drawings);
|
$drawingCount = count($drawings);
|
||||||
if ($this->_includeCharts) {
|
if ($this->_includeCharts) {
|
||||||
$chartCount = $this->_spreadSheet->getSheet($i)->getChartCount();
|
$chartCount = $this->_spreadSheet->getSheet($i)->getChartCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add drawing and image relationship parts
|
// Add drawing and image relationship parts
|
||||||
if (($drawingCount > 0) || ($chartCount > 0)) {
|
if (($drawingCount > 0) || ($chartCount > 0)) {
|
||||||
// Drawing relationships
|
// Drawing relationships
|
||||||
$objZip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->_spreadSheet->getSheet($i),$chartRef1, $this->_includeCharts));
|
$objZip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->_spreadSheet->getSheet($i),$chartRef1, $this->_includeCharts));
|
||||||
|
|
||||||
// Drawings
|
// Drawings
|
||||||
$objZip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->_spreadSheet->getSheet($i),$chartRef2,$this->_includeCharts));
|
$objZip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->_spreadSheet->getSheet($i),$chartRef2,$this->_includeCharts));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add comment relationship parts
|
// Add comment relationship parts
|
||||||
if (count($this->_spreadSheet->getSheet($i)->getComments()) > 0) {
|
if (count($this->_spreadSheet->getSheet($i)->getComments()) > 0) {
|
||||||
// VML Comments
|
// VML Comments
|
||||||
$objZip->addFromString('xl/drawings/vmlDrawing' . ($i + 1) . '.vml', $this->getWriterPart('Comments')->writeVMLComments($this->_spreadSheet->getSheet($i)));
|
$objZip->addFromString('xl/drawings/vmlDrawing' . ($i + 1) . '.vml', $this->getWriterPart('Comments')->writeVMLComments($this->_spreadSheet->getSheet($i)));
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
$objZip->addFromString('xl/comments' . ($i + 1) . '.xml', $this->getWriterPart('Comments')->writeComments($this->_spreadSheet->getSheet($i)));
|
$objZip->addFromString('xl/comments' . ($i + 1) . '.xml', $this->getWriterPart('Comments')->writeComments($this->_spreadSheet->getSheet($i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add header/footer relationship parts
|
// Add header/footer relationship parts
|
||||||
if (count($this->_spreadSheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) {
|
if (count($this->_spreadSheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) {
|
||||||
// VML Drawings
|
// VML Drawings
|
||||||
$objZip->addFromString('xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml', $this->getWriterPart('Drawing')->writeVMLHeaderFooterImages($this->_spreadSheet->getSheet($i)));
|
$objZip->addFromString('xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml', $this->getWriterPart('Drawing')->writeVMLHeaderFooterImages($this->_spreadSheet->getSheet($i)));
|
||||||
|
|
||||||
// VML Drawing relationships
|
// VML Drawing relationships
|
||||||
$objZip->addFromString('xl/drawings/_rels/vmlDrawingHF' . ($i + 1) . '.vml.rels', $this->getWriterPart('Rels')->writeHeaderFooterDrawingRelationships($this->_spreadSheet->getSheet($i)));
|
$objZip->addFromString('xl/drawings/_rels/vmlDrawingHF' . ($i + 1) . '.vml.rels', $this->getWriterPart('Rels')->writeHeaderFooterDrawingRelationships($this->_spreadSheet->getSheet($i)));
|
||||||
|
|
||||||
// Media
|
// Media
|
||||||
foreach ($this->_spreadSheet->getSheet($i)->getHeaderFooter()->getImages() as $image) {
|
foreach ($this->_spreadSheet->getSheet($i)->getHeaderFooter()->getImages() as $image) {
|
||||||
$objZip->addFromString('xl/media/' . $image->getIndexedFilename(), file_get_contents($image->getPath()));
|
$objZip->addFromString('xl/media/' . $image->getIndexedFilename(), file_get_contents($image->getPath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add media
|
// Add media
|
||||||
for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
|
for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
|
||||||
if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
|
if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
|
||||||
$imageContents = null;
|
$imageContents = null;
|
||||||
$imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
|
$imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
|
||||||
if (strpos($imagePath, 'zip://') !== false) {
|
if (strpos($imagePath, 'zip://') !== false) {
|
||||||
$imagePath = substr($imagePath, 6);
|
$imagePath = substr($imagePath, 6);
|
||||||
$imagePathSplitted = explode('#', $imagePath);
|
$imagePathSplitted = explode('#', $imagePath);
|
||||||
|
|
||||||
$imageZip = new ZipArchive();
|
$imageZip = new ZipArchive();
|
||||||
$imageZip->open($imagePathSplitted[0]);
|
$imageZip->open($imagePathSplitted[0]);
|
||||||
$imageContents = $imageZip->getFromName($imagePathSplitted[1]);
|
$imageContents = $imageZip->getFromName($imagePathSplitted[1]);
|
||||||
$imageZip->close();
|
$imageZip->close();
|
||||||
unset($imageZip);
|
unset($imageZip);
|
||||||
} else {
|
} else {
|
||||||
$imageContents = file_get_contents($imagePath);
|
$imageContents = file_get_contents($imagePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objZip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
$objZip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||||
} else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
} else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
||||||
ob_start();
|
ob_start();
|
||||||
call_user_func(
|
call_user_func(
|
||||||
$this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
|
$this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
|
||||||
$this->getDrawingHashTable()->getByIndex($i)->getImageResource()
|
$this->getDrawingHashTable()->getByIndex($i)->getImageResource()
|
||||||
);
|
);
|
||||||
$imageContents = ob_get_contents();
|
$imageContents = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
$objZip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
$objZip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
|
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
|
||||||
PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
if ($objZip->close() === false) {
|
if ($objZip->close() === false) {
|
||||||
throw new PHPExcel_Writer_Exception("Could not close zip file $pFilename.");
|
throw new PHPExcel_Writer_Exception("Could not close zip file $pFilename.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a temporary file was used, copy it to the correct file stream
|
// If a temporary file was used, copy it to the correct file stream
|
||||||
if ($originalFilename != $pFilename) {
|
if ($originalFilename != $pFilename) {
|
||||||
if (copy($pFilename, $originalFilename) === false) {
|
if (copy($pFilename, $originalFilename) === false) {
|
||||||
throw new PHPExcel_Writer_Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
|
throw new PHPExcel_Writer_Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
|
||||||
}
|
}
|
||||||
@unlink($pFilename);
|
@unlink($pFilename);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("PHPExcel object unassigned.");
|
throw new PHPExcel_Writer_Exception("PHPExcel object unassigned.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get PHPExcel object
|
* Get PHPExcel object
|
||||||
*
|
*
|
||||||
* @return PHPExcel
|
* @return PHPExcel
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function getPHPExcel() {
|
public function getPHPExcel() {
|
||||||
if ($this->_spreadSheet !== null) {
|
if ($this->_spreadSheet !== null) {
|
||||||
return $this->_spreadSheet;
|
return $this->_spreadSheet;
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("No PHPExcel assigned.");
|
throw new PHPExcel_Writer_Exception("No PHPExcel assigned.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set PHPExcel object
|
* Set PHPExcel object
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel PHPExcel object
|
* @param PHPExcel $pPHPExcel PHPExcel object
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
* @return PHPExcel_Writer_Excel2007
|
* @return PHPExcel_Writer_Excel2007
|
||||||
*/
|
*/
|
||||||
public function setPHPExcel(PHPExcel $pPHPExcel = null) {
|
public function setPHPExcel(PHPExcel $pPHPExcel = null) {
|
||||||
$this->_spreadSheet = $pPHPExcel;
|
$this->_spreadSheet = $pPHPExcel;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get string table
|
* Get string table
|
||||||
@ -443,7 +435,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getStringTable() {
|
public function getStringTable() {
|
||||||
return $this->_stringTable;
|
return $this->_stringTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -452,7 +444,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
* @return PHPExcel_HashTable
|
* @return PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
public function getStyleHashTable() {
|
public function getStyleHashTable() {
|
||||||
return $this->_styleHashTable;
|
return $this->_styleHashTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -461,7 +453,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
* @return PHPExcel_HashTable
|
* @return PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
public function getStylesConditionalHashTable() {
|
public function getStylesConditionalHashTable() {
|
||||||
return $this->_stylesConditionalHashTable;
|
return $this->_stylesConditionalHashTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -470,7 +462,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
* @return PHPExcel_HashTable
|
* @return PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
public function getFillHashTable() {
|
public function getFillHashTable() {
|
||||||
return $this->_fillHashTable;
|
return $this->_fillHashTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -479,7 +471,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
* @return PHPExcel_HashTable
|
* @return PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
public function getFontHashTable() {
|
public function getFontHashTable() {
|
||||||
return $this->_fontHashTable;
|
return $this->_fontHashTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -488,7 +480,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
* @return PHPExcel_HashTable
|
* @return PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
public function getBordersHashTable() {
|
public function getBordersHashTable() {
|
||||||
return $this->_bordersHashTable;
|
return $this->_bordersHashTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -497,7 +489,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
* @return PHPExcel_HashTable
|
* @return PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
public function getNumFmtHashTable() {
|
public function getNumFmtHashTable() {
|
||||||
return $this->_numFmtHashTable;
|
return $this->_numFmtHashTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -506,7 +498,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
* @return PHPExcel_HashTable
|
* @return PHPExcel_HashTable
|
||||||
*/
|
*/
|
||||||
public function getDrawingHashTable() {
|
public function getDrawingHashTable() {
|
||||||
return $this->_drawingHashTable;
|
return $this->_drawingHashTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -515,18 +507,18 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getOffice2003Compatibility() {
|
public function getOffice2003Compatibility() {
|
||||||
return $this->_office2003compatibility;
|
return $this->_office2003compatibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Office2003 compatibility
|
* Set Office2003 compatibility
|
||||||
*
|
*
|
||||||
* @param boolean $pValue Office2003 compatibility?
|
* @param boolean $pValue Office2003 compatibility?
|
||||||
* @return PHPExcel_Writer_Excel2007
|
* @return PHPExcel_Writer_Excel2007
|
||||||
*/
|
*/
|
||||||
public function setOffice2003Compatibility($pValue = false) {
|
public function setOffice2003Compatibility($pValue = false) {
|
||||||
$this->_office2003compatibility = $pValue;
|
$this->_office2003compatibility = $pValue;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel2007
|
* @package PHPExcel_Writer_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ class PHPExcel_Writer_Excel2007_Chart extends
|
|||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
// Ensure that data series values are up-to-date before we save
|
// Ensure that data series values are up-to-date before we save
|
||||||
$pChart->refresh();
|
$pChart->refresh();
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
@ -284,7 +284,7 @@ class PHPExcel_Writer_Excel2007_Chart extends
|
|||||||
$this->_writeDataLbls($objWriter, $layout);
|
$this->_writeDataLbls($objWriter, $layout);
|
||||||
|
|
||||||
if ($chartType === PHPExcel_Chart_DataSeries::TYPE_LINECHART) {
|
if ($chartType === PHPExcel_Chart_DataSeries::TYPE_LINECHART) {
|
||||||
// Line only, Line3D can't be smoothed
|
// Line only, Line3D can't be smoothed
|
||||||
|
|
||||||
$objWriter->startElement('c:smooth');
|
$objWriter->startElement('c:smooth');
|
||||||
$objWriter->writeAttribute('val', (integer) $plotGroup->getSmoothLine());
|
$objWriter->writeAttribute('val', (integer) $plotGroup->getSmoothLine());
|
||||||
@ -334,11 +334,11 @@ class PHPExcel_Writer_Excel2007_Chart extends
|
|||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate 2 unique numbers to use for axId values
|
// Generate 2 unique numbers to use for axId values
|
||||||
// $id1 = $id2 = rand(10000000,99999999);
|
// $id1 = $id2 = rand(10000000,99999999);
|
||||||
// do {
|
// do {
|
||||||
// $id2 = rand(10000000,99999999);
|
// $id2 = rand(10000000,99999999);
|
||||||
// } while ($id1 == $id2);
|
// } while ($id1 == $id2);
|
||||||
$id1 = '75091328';
|
$id1 = '75091328';
|
||||||
$id2 = '75089408';
|
$id2 = '75089408';
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ class PHPExcel_Writer_Excel2007_Chart extends
|
|||||||
$caption = $caption[0];
|
$caption = $caption[0];
|
||||||
}
|
}
|
||||||
$objWriter->startElement('a:t');
|
$objWriter->startElement('a:t');
|
||||||
// $objWriter->writeAttribute('xml:space', 'preserve');
|
// $objWriter->writeAttribute('xml:space', 'preserve');
|
||||||
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($caption));
|
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($caption));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
@ -840,7 +840,7 @@ class PHPExcel_Writer_Excel2007_Chart extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->startElement('a:t');
|
$objWriter->startElement('a:t');
|
||||||
// $objWriter->writeAttribute('xml:space', 'preserve');
|
// $objWriter->writeAttribute('xml:space', 'preserve');
|
||||||
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($caption));
|
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML($caption));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
@ -1117,7 +1117,7 @@ class PHPExcel_Writer_Excel2007_Chart extends
|
|||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get these details before the loop, because we can use the count to check for varyColors
|
// Get these details before the loop, because we can use the count to check for varyColors
|
||||||
$plotSeriesOrder = $plotGroup->getPlotOrder();
|
$plotSeriesOrder = $plotGroup->getPlotOrder();
|
||||||
$plotSeriesCount = count($plotSeriesOrder);
|
$plotSeriesCount = count($plotSeriesOrder);
|
||||||
|
|
||||||
@ -1177,7 +1177,7 @@ class PHPExcel_Writer_Excel2007_Chart extends
|
|||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Labels
|
// Labels
|
||||||
$plotSeriesLabel = $plotGroup->getPlotLabelByIndex($plotSeriesRef);
|
$plotSeriesLabel = $plotGroup->getPlotLabelByIndex($plotSeriesRef);
|
||||||
if ($plotSeriesLabel && ($plotSeriesLabel->getPointCount() > 0)) {
|
if ($plotSeriesLabel && ($plotSeriesLabel->getPointCount() > 0)) {
|
||||||
$objWriter->startElement('c:tx');
|
$objWriter->startElement('c:tx');
|
||||||
@ -1187,7 +1187,7 @@ class PHPExcel_Writer_Excel2007_Chart extends
|
|||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Formatting for the points
|
// Formatting for the points
|
||||||
if (($groupType == PHPExcel_Chart_DataSeries::TYPE_LINECHART) ||
|
if (($groupType == PHPExcel_Chart_DataSeries::TYPE_LINECHART) ||
|
||||||
($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)
|
($groupType == PHPExcel_Chart_DataSeries::TYPE_STOCKCHART)
|
||||||
) {
|
) {
|
||||||
@ -1231,7 +1231,7 @@ class PHPExcel_Writer_Excel2007_Chart extends
|
|||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Category Labels
|
// Category Labels
|
||||||
$plotSeriesCategory = $plotGroup->getPlotCategoryByIndex($plotSeriesRef);
|
$plotSeriesCategory = $plotGroup->getPlotCategoryByIndex($plotSeriesRef);
|
||||||
if ($plotSeriesCategory && ($plotSeriesCategory->getPointCount() > 0)) {
|
if ($plotSeriesCategory && ($plotSeriesCategory->getPointCount() > 0)) {
|
||||||
$catIsMultiLevelSeries = $catIsMultiLevelSeries || $plotSeriesCategory->isMultiLevelSeries();
|
$catIsMultiLevelSeries = $catIsMultiLevelSeries || $plotSeriesCategory->isMultiLevelSeries();
|
||||||
@ -1263,7 +1263,7 @@ class PHPExcel_Writer_Excel2007_Chart extends
|
|||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values
|
// Values
|
||||||
if ($plotSeriesValues) {
|
if ($plotSeriesValues) {
|
||||||
$valIsMultiLevelSeries = $valIsMultiLevelSeries || $plotSeriesValues->isMultiLevelSeries();
|
$valIsMultiLevelSeries = $valIsMultiLevelSeries || $plotSeriesValues->isMultiLevelSeries();
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel2007
|
* @package PHPExcel_Writer_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,234 +35,234 @@
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_WriterPart
|
class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write comments to XML format
|
* Write comments to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Worksheet $pWorksheet
|
* @param PHPExcel_Worksheet $pWorksheet
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeComments(PHPExcel_Worksheet $pWorksheet = null)
|
public function writeComments(PHPExcel_Worksheet $pWorksheet = null)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Comments cache
|
// Comments cache
|
||||||
$comments = $pWorksheet->getComments();
|
$comments = $pWorksheet->getComments();
|
||||||
|
|
||||||
// Authors cache
|
// Authors cache
|
||||||
$authors = array();
|
$authors = array();
|
||||||
$authorId = 0;
|
$authorId = 0;
|
||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
if (!isset($authors[$comment->getAuthor()])) {
|
if (!isset($authors[$comment->getAuthor()])) {
|
||||||
$authors[$comment->getAuthor()] = $authorId++;
|
$authors[$comment->getAuthor()] = $authorId++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// comments
|
// comments
|
||||||
$objWriter->startElement('comments');
|
$objWriter->startElement('comments');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
||||||
|
|
||||||
// Loop through authors
|
// Loop through authors
|
||||||
$objWriter->startElement('authors');
|
$objWriter->startElement('authors');
|
||||||
foreach ($authors as $author => $index) {
|
foreach ($authors as $author => $index) {
|
||||||
$objWriter->writeElement('author', $author);
|
$objWriter->writeElement('author', $author);
|
||||||
}
|
}
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Loop through comments
|
// Loop through comments
|
||||||
$objWriter->startElement('commentList');
|
$objWriter->startElement('commentList');
|
||||||
foreach ($comments as $key => $value) {
|
foreach ($comments as $key => $value) {
|
||||||
$this->_writeComment($objWriter, $key, $value, $authors);
|
$this->_writeComment($objWriter, $key, $value, $authors);
|
||||||
}
|
}
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write comment to XML format
|
* Write comment to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param string $pCellReference Cell reference
|
* @param string $pCellReference Cell reference
|
||||||
* @param PHPExcel_Comment $pComment Comment
|
* @param PHPExcel_Comment $pComment Comment
|
||||||
* @param array $pAuthors Array of authors
|
* @param array $pAuthors Array of authors
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function _writeComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null, $pAuthors = null)
|
public function _writeComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null, $pAuthors = null)
|
||||||
{
|
{
|
||||||
// comment
|
// comment
|
||||||
$objWriter->startElement('comment');
|
$objWriter->startElement('comment');
|
||||||
$objWriter->writeAttribute('ref', $pCellReference);
|
$objWriter->writeAttribute('ref', $pCellReference);
|
||||||
$objWriter->writeAttribute('authorId', $pAuthors[$pComment->getAuthor()]);
|
$objWriter->writeAttribute('authorId', $pAuthors[$pComment->getAuthor()]);
|
||||||
|
|
||||||
// text
|
// text
|
||||||
$objWriter->startElement('text');
|
$objWriter->startElement('text');
|
||||||
$this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $pComment->getText());
|
$this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $pComment->getText());
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write VML comments to XML format
|
* Write VML comments to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Worksheet $pWorksheet
|
* @param PHPExcel_Worksheet $pWorksheet
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeVMLComments(PHPExcel_Worksheet $pWorksheet = null)
|
public function writeVMLComments(PHPExcel_Worksheet $pWorksheet = null)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Comments cache
|
// Comments cache
|
||||||
$comments = $pWorksheet->getComments();
|
$comments = $pWorksheet->getComments();
|
||||||
|
|
||||||
// xml
|
// xml
|
||||||
$objWriter->startElement('xml');
|
$objWriter->startElement('xml');
|
||||||
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
|
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
|
||||||
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
|
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
|
||||||
$objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
|
$objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
|
||||||
|
|
||||||
// o:shapelayout
|
// o:shapelayout
|
||||||
$objWriter->startElement('o:shapelayout');
|
$objWriter->startElement('o:shapelayout');
|
||||||
$objWriter->writeAttribute('v:ext', 'edit');
|
$objWriter->writeAttribute('v:ext', 'edit');
|
||||||
|
|
||||||
// o:idmap
|
// o:idmap
|
||||||
$objWriter->startElement('o:idmap');
|
$objWriter->startElement('o:idmap');
|
||||||
$objWriter->writeAttribute('v:ext', 'edit');
|
$objWriter->writeAttribute('v:ext', 'edit');
|
||||||
$objWriter->writeAttribute('data', '1');
|
$objWriter->writeAttribute('data', '1');
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// v:shapetype
|
// v:shapetype
|
||||||
$objWriter->startElement('v:shapetype');
|
$objWriter->startElement('v:shapetype');
|
||||||
$objWriter->writeAttribute('id', '_x0000_t202');
|
$objWriter->writeAttribute('id', '_x0000_t202');
|
||||||
$objWriter->writeAttribute('coordsize', '21600,21600');
|
$objWriter->writeAttribute('coordsize', '21600,21600');
|
||||||
$objWriter->writeAttribute('o:spt', '202');
|
$objWriter->writeAttribute('o:spt', '202');
|
||||||
$objWriter->writeAttribute('path', 'm,l,21600r21600,l21600,xe');
|
$objWriter->writeAttribute('path', 'm,l,21600r21600,l21600,xe');
|
||||||
|
|
||||||
// v:stroke
|
// v:stroke
|
||||||
$objWriter->startElement('v:stroke');
|
$objWriter->startElement('v:stroke');
|
||||||
$objWriter->writeAttribute('joinstyle', 'miter');
|
$objWriter->writeAttribute('joinstyle', 'miter');
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// v:path
|
// v:path
|
||||||
$objWriter->startElement('v:path');
|
$objWriter->startElement('v:path');
|
||||||
$objWriter->writeAttribute('gradientshapeok', 't');
|
$objWriter->writeAttribute('gradientshapeok', 't');
|
||||||
$objWriter->writeAttribute('o:connecttype', 'rect');
|
$objWriter->writeAttribute('o:connecttype', 'rect');
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Loop through comments
|
// Loop through comments
|
||||||
foreach ($comments as $key => $value) {
|
foreach ($comments as $key => $value) {
|
||||||
$this->_writeVMLComment($objWriter, $key, $value);
|
$this->_writeVMLComment($objWriter, $key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write VML comment to XML format
|
* Write VML comment to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param string $pCellReference Cell reference
|
* @param string $pCellReference Cell reference
|
||||||
* @param PHPExcel_Comment $pComment Comment
|
* @param PHPExcel_Comment $pComment Comment
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function _writeVMLComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null)
|
public function _writeVMLComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null)
|
||||||
{
|
{
|
||||||
// Metadata
|
// Metadata
|
||||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($pCellReference);
|
list($column, $row) = PHPExcel_Cell::coordinateFromString($pCellReference);
|
||||||
$column = PHPExcel_Cell::columnIndexFromString($column);
|
$column = PHPExcel_Cell::columnIndexFromString($column);
|
||||||
$id = 1024 + $column + $row;
|
$id = 1024 + $column + $row;
|
||||||
$id = substr($id, 0, 4);
|
$id = substr($id, 0, 4);
|
||||||
|
|
||||||
// v:shape
|
// v:shape
|
||||||
$objWriter->startElement('v:shape');
|
$objWriter->startElement('v:shape');
|
||||||
$objWriter->writeAttribute('id', '_x0000_s' . $id);
|
$objWriter->writeAttribute('id', '_x0000_s' . $id);
|
||||||
$objWriter->writeAttribute('type', '#_x0000_t202');
|
$objWriter->writeAttribute('type', '#_x0000_t202');
|
||||||
$objWriter->writeAttribute('style', 'position:absolute;margin-left:' . $pComment->getMarginLeft() . ';margin-top:' . $pComment->getMarginTop() . ';width:' . $pComment->getWidth() . ';height:' . $pComment->getHeight() . ';z-index:1;visibility:' . ($pComment->getVisible() ? 'visible' : 'hidden'));
|
$objWriter->writeAttribute('style', 'position:absolute;margin-left:' . $pComment->getMarginLeft() . ';margin-top:' . $pComment->getMarginTop() . ';width:' . $pComment->getWidth() . ';height:' . $pComment->getHeight() . ';z-index:1;visibility:' . ($pComment->getVisible() ? 'visible' : 'hidden'));
|
||||||
$objWriter->writeAttribute('fillcolor', '#' . $pComment->getFillColor()->getRGB());
|
$objWriter->writeAttribute('fillcolor', '#' . $pComment->getFillColor()->getRGB());
|
||||||
$objWriter->writeAttribute('o:insetmode', 'auto');
|
$objWriter->writeAttribute('o:insetmode', 'auto');
|
||||||
|
|
||||||
// v:fill
|
// v:fill
|
||||||
$objWriter->startElement('v:fill');
|
$objWriter->startElement('v:fill');
|
||||||
$objWriter->writeAttribute('color2', '#' . $pComment->getFillColor()->getRGB());
|
$objWriter->writeAttribute('color2', '#' . $pComment->getFillColor()->getRGB());
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// v:shadow
|
// v:shadow
|
||||||
$objWriter->startElement('v:shadow');
|
$objWriter->startElement('v:shadow');
|
||||||
$objWriter->writeAttribute('on', 't');
|
$objWriter->writeAttribute('on', 't');
|
||||||
$objWriter->writeAttribute('color', 'black');
|
$objWriter->writeAttribute('color', 'black');
|
||||||
$objWriter->writeAttribute('obscured', 't');
|
$objWriter->writeAttribute('obscured', 't');
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// v:path
|
// v:path
|
||||||
$objWriter->startElement('v:path');
|
$objWriter->startElement('v:path');
|
||||||
$objWriter->writeAttribute('o:connecttype', 'none');
|
$objWriter->writeAttribute('o:connecttype', 'none');
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// v:textbox
|
// v:textbox
|
||||||
$objWriter->startElement('v:textbox');
|
$objWriter->startElement('v:textbox');
|
||||||
$objWriter->writeAttribute('style', 'mso-direction-alt:auto');
|
$objWriter->writeAttribute('style', 'mso-direction-alt:auto');
|
||||||
|
|
||||||
// div
|
// div
|
||||||
$objWriter->startElement('div');
|
$objWriter->startElement('div');
|
||||||
$objWriter->writeAttribute('style', 'text-align:left');
|
$objWriter->writeAttribute('style', 'text-align:left');
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// x:ClientData
|
// x:ClientData
|
||||||
$objWriter->startElement('x:ClientData');
|
$objWriter->startElement('x:ClientData');
|
||||||
$objWriter->writeAttribute('ObjectType', 'Note');
|
$objWriter->writeAttribute('ObjectType', 'Note');
|
||||||
|
|
||||||
// x:MoveWithCells
|
// x:MoveWithCells
|
||||||
$objWriter->writeElement('x:MoveWithCells', '');
|
$objWriter->writeElement('x:MoveWithCells', '');
|
||||||
|
|
||||||
// x:SizeWithCells
|
// x:SizeWithCells
|
||||||
$objWriter->writeElement('x:SizeWithCells', '');
|
$objWriter->writeElement('x:SizeWithCells', '');
|
||||||
|
|
||||||
// x:Anchor
|
// x:Anchor
|
||||||
//$objWriter->writeElement('x:Anchor', $column . ', 15, ' . ($row - 2) . ', 10, ' . ($column + 4) . ', 15, ' . ($row + 5) . ', 18');
|
//$objWriter->writeElement('x:Anchor', $column . ', 15, ' . ($row - 2) . ', 10, ' . ($column + 4) . ', 15, ' . ($row + 5) . ', 18');
|
||||||
|
|
||||||
// x:AutoFill
|
// x:AutoFill
|
||||||
$objWriter->writeElement('x:AutoFill', 'False');
|
$objWriter->writeElement('x:AutoFill', 'False');
|
||||||
|
|
||||||
// x:Row
|
// x:Row
|
||||||
$objWriter->writeElement('x:Row', ($row - 1));
|
$objWriter->writeElement('x:Row', ($row - 1));
|
||||||
|
|
||||||
// x:Column
|
// x:Column
|
||||||
$objWriter->writeElement('x:Column', ($column - 1));
|
$objWriter->writeElement('x:Column', ($column - 1));
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel2007
|
* @package PHPExcel_Writer_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,253 +35,253 @@
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_WriterPart
|
class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write content types to XML format
|
* Write content types to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @param boolean $includeCharts Flag indicating if we should include drawing details for charts
|
* @param boolean $includeCharts Flag indicating if we should include drawing details for charts
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeContentTypes(PHPExcel $pPHPExcel = null, $includeCharts = FALSE)
|
public function writeContentTypes(PHPExcel $pPHPExcel = null, $includeCharts = FALSE)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
$objWriter->startElement('Types');
|
$objWriter->startElement('Types');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
|
||||||
|
|
||||||
// Theme
|
// Theme
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/xl/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
|
$objWriter, '/xl/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/xl/styles.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'
|
$objWriter, '/xl/styles.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Rels
|
// Rels
|
||||||
$this->_writeDefaultContentType(
|
$this->_writeDefaultContentType(
|
||||||
$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
|
$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// XML
|
// XML
|
||||||
$this->_writeDefaultContentType(
|
$this->_writeDefaultContentType(
|
||||||
$objWriter, 'xml', 'application/xml'
|
$objWriter, 'xml', 'application/xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// VML
|
// VML
|
||||||
$this->_writeDefaultContentType(
|
$this->_writeDefaultContentType(
|
||||||
$objWriter, 'vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing'
|
$objWriter, 'vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Workbook
|
// Workbook
|
||||||
if($pPHPExcel->hasMacros()){ //Macros in workbook ?
|
if($pPHPExcel->hasMacros()){ //Macros in workbook ?
|
||||||
// Yes : not standard content but "macroEnabled"
|
// Yes : not standard content but "macroEnabled"
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/xl/workbook.xml', 'application/vnd.ms-excel.sheet.macroEnabled.main+xml'
|
$objWriter, '/xl/workbook.xml', 'application/vnd.ms-excel.sheet.macroEnabled.main+xml'
|
||||||
);
|
);
|
||||||
//... and define a new type for the VBA project
|
//... and define a new type for the VBA project
|
||||||
$this->_writeDefaultContentType(
|
$this->_writeDefaultContentType(
|
||||||
$objWriter, 'bin', 'application/vnd.ms-office.vbaProject'
|
$objWriter, 'bin', 'application/vnd.ms-office.vbaProject'
|
||||||
);
|
);
|
||||||
if($pPHPExcel->hasMacrosCertificate()){// signed macros ?
|
if($pPHPExcel->hasMacrosCertificate()){// signed macros ?
|
||||||
// Yes : add needed information
|
// Yes : add needed information
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/xl/vbaProjectSignature.bin', 'application/vnd.ms-office.vbaProjectSignature'
|
$objWriter, '/xl/vbaProjectSignature.bin', 'application/vnd.ms-office.vbaProjectSignature'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}else{// no macros in workbook, so standard type
|
}else{// no macros in workbook, so standard type
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'
|
$objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DocProps
|
// DocProps
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
|
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
||||||
if (!empty($customPropertyList)) {
|
if (!empty($customPropertyList)) {
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml'
|
$objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Worksheets
|
// Worksheets
|
||||||
$sheetCount = $pPHPExcel->getSheetCount();
|
$sheetCount = $pPHPExcel->getSheetCount();
|
||||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/xl/worksheets/sheet' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'
|
$objWriter, '/xl/worksheets/sheet' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shared strings
|
// Shared strings
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'
|
$objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add worksheet relationship content types
|
// Add worksheet relationship content types
|
||||||
$chart = 1;
|
$chart = 1;
|
||||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||||
$drawings = $pPHPExcel->getSheet($i)->getDrawingCollection();
|
$drawings = $pPHPExcel->getSheet($i)->getDrawingCollection();
|
||||||
$drawingCount = count($drawings);
|
$drawingCount = count($drawings);
|
||||||
$chartCount = ($includeCharts) ? $pPHPExcel->getSheet($i)->getChartCount() : 0;
|
$chartCount = ($includeCharts) ? $pPHPExcel->getSheet($i)->getChartCount() : 0;
|
||||||
|
|
||||||
// We need a drawing relationship for the worksheet if we have either drawings or charts
|
// We need a drawing relationship for the worksheet if we have either drawings or charts
|
||||||
if (($drawingCount > 0) || ($chartCount > 0)) {
|
if (($drawingCount > 0) || ($chartCount > 0)) {
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/xl/drawings/drawing' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.drawing+xml'
|
$objWriter, '/xl/drawings/drawing' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.drawing+xml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have charts, then we need a chart relationship for every individual chart
|
// If we have charts, then we need a chart relationship for every individual chart
|
||||||
if ($chartCount > 0) {
|
if ($chartCount > 0) {
|
||||||
for ($c = 0; $c < $chartCount; ++$c) {
|
for ($c = 0; $c < $chartCount; ++$c) {
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/xl/charts/chart' . $chart++ . '.xml', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml'
|
$objWriter, '/xl/charts/chart' . $chart++ . '.xml', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||||
if (count($pPHPExcel->getSheet($i)->getComments()) > 0) {
|
if (count($pPHPExcel->getSheet($i)->getComments()) > 0) {
|
||||||
$this->_writeOverrideContentType(
|
$this->_writeOverrideContentType(
|
||||||
$objWriter, '/xl/comments' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'
|
$objWriter, '/xl/comments' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add media content-types
|
// Add media content-types
|
||||||
$aMediaContentTypes = array();
|
$aMediaContentTypes = array();
|
||||||
$mediaCount = $this->getParentWriter()->getDrawingHashTable()->count();
|
$mediaCount = $this->getParentWriter()->getDrawingHashTable()->count();
|
||||||
for ($i = 0; $i < $mediaCount; ++$i) {
|
for ($i = 0; $i < $mediaCount; ++$i) {
|
||||||
$extension = '';
|
$extension = '';
|
||||||
$mimeType = '';
|
$mimeType = '';
|
||||||
|
|
||||||
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
|
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
|
||||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
|
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
|
||||||
$mimeType = $this->_getImageMimeType( $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath() );
|
$mimeType = $this->_getImageMimeType( $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath() );
|
||||||
} else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
} else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
||||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
|
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
|
||||||
$extension = explode('/', $extension);
|
$extension = explode('/', $extension);
|
||||||
$extension = $extension[1];
|
$extension = $extension[1];
|
||||||
|
|
||||||
$mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
|
$mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset( $aMediaContentTypes[$extension]) ) {
|
if (!isset( $aMediaContentTypes[$extension]) ) {
|
||||||
$aMediaContentTypes[$extension] = $mimeType;
|
$aMediaContentTypes[$extension] = $mimeType;
|
||||||
|
|
||||||
$this->_writeDefaultContentType(
|
$this->_writeDefaultContentType(
|
||||||
$objWriter, $extension, $mimeType
|
$objWriter, $extension, $mimeType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($pPHPExcel->hasRibbonBinObjects()){//Some additional objects in the ribbon ?
|
if($pPHPExcel->hasRibbonBinObjects()){//Some additional objects in the ribbon ?
|
||||||
//we need to write "Extension" but not already write for media content
|
//we need to write "Extension" but not already write for media content
|
||||||
$tabRibbonTypes=array_diff($pPHPExcel->getRibbonBinObjects('types'), array_keys($aMediaContentTypes));
|
$tabRibbonTypes=array_diff($pPHPExcel->getRibbonBinObjects('types'), array_keys($aMediaContentTypes));
|
||||||
foreach($tabRibbonTypes as $aRibbonType){
|
foreach($tabRibbonTypes as $aRibbonType){
|
||||||
$mimeType='image/.'.$aRibbonType;//we wrote $mimeType like customUI Editor
|
$mimeType='image/.'.$aRibbonType;//we wrote $mimeType like customUI Editor
|
||||||
$this->_writeDefaultContentType(
|
$this->_writeDefaultContentType(
|
||||||
$objWriter, $aRibbonType, $mimeType
|
$objWriter, $aRibbonType, $mimeType
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sheetCount = $pPHPExcel->getSheetCount();
|
$sheetCount = $pPHPExcel->getSheetCount();
|
||||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||||
if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) {
|
if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) {
|
||||||
foreach ($pPHPExcel->getSheet()->getHeaderFooter()->getImages() as $image) {
|
foreach ($pPHPExcel->getSheet()->getHeaderFooter()->getImages() as $image) {
|
||||||
if (!isset( $aMediaContentTypes[strtolower($image->getExtension())]) ) {
|
if (!isset( $aMediaContentTypes[strtolower($image->getExtension())]) ) {
|
||||||
$aMediaContentTypes[strtolower($image->getExtension())] = $this->_getImageMimeType( $image->getPath() );
|
$aMediaContentTypes[strtolower($image->getExtension())] = $this->_getImageMimeType( $image->getPath() );
|
||||||
|
|
||||||
$this->_writeDefaultContentType(
|
$this->_writeDefaultContentType(
|
||||||
$objWriter, strtolower($image->getExtension()), $aMediaContentTypes[strtolower($image->getExtension())]
|
$objWriter, strtolower($image->getExtension()), $aMediaContentTypes[strtolower($image->getExtension())]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get image mime type
|
* Get image mime type
|
||||||
*
|
*
|
||||||
* @param string $pFile Filename
|
* @param string $pFile Filename
|
||||||
* @return string Mime Type
|
* @return string Mime Type
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _getImageMimeType($pFile = '')
|
private function _getImageMimeType($pFile = '')
|
||||||
{
|
{
|
||||||
if (PHPExcel_Shared_File::file_exists($pFile)) {
|
if (PHPExcel_Shared_File::file_exists($pFile)) {
|
||||||
$image = getimagesize($pFile);
|
$image = getimagesize($pFile);
|
||||||
return image_type_to_mime_type($image[2]);
|
return image_type_to_mime_type($image[2]);
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("File $pFile does not exist");
|
throw new PHPExcel_Writer_Exception("File $pFile does not exist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Default content type
|
* Write Default content type
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param string $pPartname Part name
|
* @param string $pPartname Part name
|
||||||
* @param string $pContentType Content type
|
* @param string $pContentType Content type
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeDefaultContentType(PHPExcel_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
private function _writeDefaultContentType(PHPExcel_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||||
{
|
{
|
||||||
if ($pPartname != '' && $pContentType != '') {
|
if ($pPartname != '' && $pContentType != '') {
|
||||||
// Write content type
|
// Write content type
|
||||||
$objWriter->startElement('Default');
|
$objWriter->startElement('Default');
|
||||||
$objWriter->writeAttribute('Extension', $pPartname);
|
$objWriter->writeAttribute('Extension', $pPartname);
|
||||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Override content type
|
* Write Override content type
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param string $pPartname Part name
|
* @param string $pPartname Part name
|
||||||
* @param string $pContentType Content type
|
* @param string $pContentType Content type
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeOverrideContentType(PHPExcel_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
private function _writeOverrideContentType(PHPExcel_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||||
{
|
{
|
||||||
if ($pPartname != '' && $pContentType != '') {
|
if ($pPartname != '' && $pContentType != '') {
|
||||||
// Write content type
|
// Write content type
|
||||||
$objWriter->startElement('Override');
|
$objWriter->startElement('Override');
|
||||||
$objWriter->writeAttribute('PartName', $pPartname);
|
$objWriter->writeAttribute('PartName', $pPartname);
|
||||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel2007
|
* @package PHPExcel_Writer_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -36,237 +36,237 @@
|
|||||||
class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart
|
class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write docProps/app.xml to XML format
|
* Write docProps/app.xml to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeDocPropsApp(PHPExcel $pPHPExcel = null)
|
public function writeDocPropsApp(PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
$objWriter->startElement('Properties');
|
$objWriter->startElement('Properties');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
|
||||||
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
||||||
|
|
||||||
// Application
|
// Application
|
||||||
$objWriter->writeElement('Application', 'Microsoft Excel');
|
$objWriter->writeElement('Application', 'Microsoft Excel');
|
||||||
|
|
||||||
// DocSecurity
|
// DocSecurity
|
||||||
$objWriter->writeElement('DocSecurity', '0');
|
$objWriter->writeElement('DocSecurity', '0');
|
||||||
|
|
||||||
// ScaleCrop
|
// ScaleCrop
|
||||||
$objWriter->writeElement('ScaleCrop', 'false');
|
$objWriter->writeElement('ScaleCrop', 'false');
|
||||||
|
|
||||||
// HeadingPairs
|
// HeadingPairs
|
||||||
$objWriter->startElement('HeadingPairs');
|
$objWriter->startElement('HeadingPairs');
|
||||||
|
|
||||||
// Vector
|
// Vector
|
||||||
$objWriter->startElement('vt:vector');
|
$objWriter->startElement('vt:vector');
|
||||||
$objWriter->writeAttribute('size', '2');
|
$objWriter->writeAttribute('size', '2');
|
||||||
$objWriter->writeAttribute('baseType', 'variant');
|
$objWriter->writeAttribute('baseType', 'variant');
|
||||||
|
|
||||||
// Variant
|
// Variant
|
||||||
$objWriter->startElement('vt:variant');
|
$objWriter->startElement('vt:variant');
|
||||||
$objWriter->writeElement('vt:lpstr', 'Worksheets');
|
$objWriter->writeElement('vt:lpstr', 'Worksheets');
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Variant
|
// Variant
|
||||||
$objWriter->startElement('vt:variant');
|
$objWriter->startElement('vt:variant');
|
||||||
$objWriter->writeElement('vt:i4', $pPHPExcel->getSheetCount());
|
$objWriter->writeElement('vt:i4', $pPHPExcel->getSheetCount());
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// TitlesOfParts
|
// TitlesOfParts
|
||||||
$objWriter->startElement('TitlesOfParts');
|
$objWriter->startElement('TitlesOfParts');
|
||||||
|
|
||||||
// Vector
|
// Vector
|
||||||
$objWriter->startElement('vt:vector');
|
$objWriter->startElement('vt:vector');
|
||||||
$objWriter->writeAttribute('size', $pPHPExcel->getSheetCount());
|
$objWriter->writeAttribute('size', $pPHPExcel->getSheetCount());
|
||||||
$objWriter->writeAttribute('baseType', 'lpstr');
|
$objWriter->writeAttribute('baseType', 'lpstr');
|
||||||
|
|
||||||
$sheetCount = $pPHPExcel->getSheetCount();
|
$sheetCount = $pPHPExcel->getSheetCount();
|
||||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||||
$objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle());
|
$objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
$objWriter->writeElement('Company', $pPHPExcel->getProperties()->getCompany());
|
$objWriter->writeElement('Company', $pPHPExcel->getProperties()->getCompany());
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
$objWriter->writeElement('Manager', $pPHPExcel->getProperties()->getManager());
|
$objWriter->writeElement('Manager', $pPHPExcel->getProperties()->getManager());
|
||||||
|
|
||||||
// LinksUpToDate
|
// LinksUpToDate
|
||||||
$objWriter->writeElement('LinksUpToDate', 'false');
|
$objWriter->writeElement('LinksUpToDate', 'false');
|
||||||
|
|
||||||
// SharedDoc
|
// SharedDoc
|
||||||
$objWriter->writeElement('SharedDoc', 'false');
|
$objWriter->writeElement('SharedDoc', 'false');
|
||||||
|
|
||||||
// HyperlinksChanged
|
// HyperlinksChanged
|
||||||
$objWriter->writeElement('HyperlinksChanged', 'false');
|
$objWriter->writeElement('HyperlinksChanged', 'false');
|
||||||
|
|
||||||
// AppVersion
|
// AppVersion
|
||||||
$objWriter->writeElement('AppVersion', '12.0000');
|
$objWriter->writeElement('AppVersion', '12.0000');
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write docProps/core.xml to XML format
|
* Write docProps/core.xml to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeDocPropsCore(PHPExcel $pPHPExcel = null)
|
public function writeDocPropsCore(PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// cp:coreProperties
|
// cp:coreProperties
|
||||||
$objWriter->startElement('cp:coreProperties');
|
$objWriter->startElement('cp:coreProperties');
|
||||||
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
|
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
|
||||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||||
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
|
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
|
||||||
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
|
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
|
||||||
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||||
|
|
||||||
// dc:creator
|
// dc:creator
|
||||||
$objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
|
$objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
|
||||||
|
|
||||||
// cp:lastModifiedBy
|
// cp:lastModifiedBy
|
||||||
$objWriter->writeElement('cp:lastModifiedBy', $pPHPExcel->getProperties()->getLastModifiedBy());
|
$objWriter->writeElement('cp:lastModifiedBy', $pPHPExcel->getProperties()->getLastModifiedBy());
|
||||||
|
|
||||||
// dcterms:created
|
// dcterms:created
|
||||||
$objWriter->startElement('dcterms:created');
|
$objWriter->startElement('dcterms:created');
|
||||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||||
$objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
|
$objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// dcterms:modified
|
// dcterms:modified
|
||||||
$objWriter->startElement('dcterms:modified');
|
$objWriter->startElement('dcterms:modified');
|
||||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||||
$objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getModified()));
|
$objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getModified()));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// dc:title
|
// dc:title
|
||||||
$objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle());
|
$objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle());
|
||||||
|
|
||||||
// dc:description
|
// dc:description
|
||||||
$objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription());
|
$objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription());
|
||||||
|
|
||||||
// dc:subject
|
// dc:subject
|
||||||
$objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject());
|
$objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject());
|
||||||
|
|
||||||
// cp:keywords
|
// cp:keywords
|
||||||
$objWriter->writeElement('cp:keywords', $pPHPExcel->getProperties()->getKeywords());
|
$objWriter->writeElement('cp:keywords', $pPHPExcel->getProperties()->getKeywords());
|
||||||
|
|
||||||
// cp:category
|
// cp:category
|
||||||
$objWriter->writeElement('cp:category', $pPHPExcel->getProperties()->getCategory());
|
$objWriter->writeElement('cp:category', $pPHPExcel->getProperties()->getCategory());
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write docProps/custom.xml to XML format
|
* Write docProps/custom.xml to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeDocPropsCustom(PHPExcel $pPHPExcel = null)
|
public function writeDocPropsCustom(PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
||||||
if (empty($customPropertyList)) {
|
if (empty($customPropertyList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// cp:coreProperties
|
// cp:coreProperties
|
||||||
$objWriter->startElement('Properties');
|
$objWriter->startElement('Properties');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
|
||||||
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
||||||
|
|
||||||
|
|
||||||
foreach($customPropertyList as $key => $customProperty) {
|
foreach($customPropertyList as $key => $customProperty) {
|
||||||
$propertyValue = $pPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
|
$propertyValue = $pPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
|
||||||
$propertyType = $pPHPExcel->getProperties()->getCustomPropertyType($customProperty);
|
$propertyType = $pPHPExcel->getProperties()->getCustomPropertyType($customProperty);
|
||||||
|
|
||||||
$objWriter->startElement('property');
|
$objWriter->startElement('property');
|
||||||
$objWriter->writeAttribute('fmtid', '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}');
|
$objWriter->writeAttribute('fmtid', '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}');
|
||||||
$objWriter->writeAttribute('pid', $key+2);
|
$objWriter->writeAttribute('pid', $key+2);
|
||||||
$objWriter->writeAttribute('name', $customProperty);
|
$objWriter->writeAttribute('name', $customProperty);
|
||||||
|
|
||||||
switch($propertyType) {
|
switch($propertyType) {
|
||||||
case 'i' :
|
case 'i' :
|
||||||
$objWriter->writeElement('vt:i4', $propertyValue);
|
$objWriter->writeElement('vt:i4', $propertyValue);
|
||||||
break;
|
break;
|
||||||
case 'f' :
|
case 'f' :
|
||||||
$objWriter->writeElement('vt:r8', $propertyValue);
|
$objWriter->writeElement('vt:r8', $propertyValue);
|
||||||
break;
|
break;
|
||||||
case 'b' :
|
case 'b' :
|
||||||
$objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false');
|
$objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false');
|
||||||
break;
|
break;
|
||||||
case 'd' :
|
case 'd' :
|
||||||
$objWriter->startElement('vt:filetime');
|
$objWriter->startElement('vt:filetime');
|
||||||
$objWriter->writeRawData(date(DATE_W3C, $propertyValue));
|
$objWriter->writeRawData(date(DATE_W3C, $propertyValue));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
$objWriter->writeElement('vt:lpwstr', $propertyValue);
|
$objWriter->writeElement('vt:lpwstr', $propertyValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel2007
|
* @package PHPExcel_Writer_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,403 +35,403 @@
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPart
|
class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write relationships to XML format
|
* Write relationships to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeRelationships(PHPExcel $pPHPExcel = null)
|
public function writeRelationships(PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Relationships
|
// Relationships
|
||||||
$objWriter->startElement('Relationships');
|
$objWriter->startElement('Relationships');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||||
|
|
||||||
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
||||||
if (!empty($customPropertyList)) {
|
if (!empty($customPropertyList)) {
|
||||||
// Relationship docProps/app.xml
|
// Relationship docProps/app.xml
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
4,
|
4,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',
|
||||||
'docProps/custom.xml'
|
'docProps/custom.xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relationship docProps/app.xml
|
// Relationship docProps/app.xml
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
3,
|
3,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
|
||||||
'docProps/app.xml'
|
'docProps/app.xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Relationship docProps/core.xml
|
// Relationship docProps/core.xml
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
2,
|
2,
|
||||||
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
||||||
'docProps/core.xml'
|
'docProps/core.xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Relationship xl/workbook.xml
|
// Relationship xl/workbook.xml
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
1,
|
1,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
||||||
'xl/workbook.xml'
|
'xl/workbook.xml'
|
||||||
);
|
);
|
||||||
// a custom UI in workbook ?
|
// a custom UI in workbook ?
|
||||||
if($pPHPExcel->hasRibbon()){
|
if($pPHPExcel->hasRibbon()){
|
||||||
$this->_writeRelationShip(
|
$this->_writeRelationShip(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
5,
|
5,
|
||||||
'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility',
|
'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility',
|
||||||
$pPHPExcel->getRibbonXMLData('target')
|
$pPHPExcel->getRibbonXMLData('target')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write workbook relationships to XML format
|
* Write workbook relationships to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeWorkbookRelationships(PHPExcel $pPHPExcel = null)
|
public function writeWorkbookRelationships(PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Relationships
|
// Relationships
|
||||||
$objWriter->startElement('Relationships');
|
$objWriter->startElement('Relationships');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||||
|
|
||||||
// Relationship styles.xml
|
// Relationship styles.xml
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
1,
|
1,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
||||||
'styles.xml'
|
'styles.xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Relationship theme/theme1.xml
|
// Relationship theme/theme1.xml
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
2,
|
2,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||||
'theme/theme1.xml'
|
'theme/theme1.xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Relationship sharedStrings.xml
|
// Relationship sharedStrings.xml
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
3,
|
3,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings',
|
||||||
'sharedStrings.xml'
|
'sharedStrings.xml'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Relationships with sheets
|
// Relationships with sheets
|
||||||
$sheetCount = $pPHPExcel->getSheetCount();
|
$sheetCount = $pPHPExcel->getSheetCount();
|
||||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
($i + 1 + 3),
|
($i + 1 + 3),
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet',
|
||||||
'worksheets/sheet' . ($i + 1) . '.xml'
|
'worksheets/sheet' . ($i + 1) . '.xml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Relationships for vbaProject if needed
|
// Relationships for vbaProject if needed
|
||||||
// id : just after the last sheet
|
// id : just after the last sheet
|
||||||
if($pPHPExcel->hasMacros()){
|
if($pPHPExcel->hasMacros()){
|
||||||
$this->_writeRelationShip(
|
$this->_writeRelationShip(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
($i + 1 + 3),
|
($i + 1 + 3),
|
||||||
'http://schemas.microsoft.com/office/2006/relationships/vbaProject',
|
'http://schemas.microsoft.com/office/2006/relationships/vbaProject',
|
||||||
'vbaProject.bin'
|
'vbaProject.bin'
|
||||||
);
|
);
|
||||||
++$i;//increment i if needed for an another relation
|
++$i;//increment i if needed for an another relation
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write worksheet relationships to XML format
|
* Write worksheet relationships to XML format
|
||||||
*
|
*
|
||||||
* Numbering is as follows:
|
* Numbering is as follows:
|
||||||
* rId1 - Drawings
|
* rId1 - Drawings
|
||||||
* rId_hyperlink_x - Hyperlinks
|
* rId_hyperlink_x - Hyperlinks
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Worksheet $pWorksheet
|
* @param PHPExcel_Worksheet $pWorksheet
|
||||||
* @param int $pWorksheetId
|
* @param int $pWorksheetId
|
||||||
* @param boolean $includeCharts Flag indicating if we should write charts
|
* @param boolean $includeCharts Flag indicating if we should write charts
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = FALSE)
|
public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = FALSE)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Relationships
|
// Relationships
|
||||||
$objWriter->startElement('Relationships');
|
$objWriter->startElement('Relationships');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||||
|
|
||||||
// Write drawing relationships?
|
// Write drawing relationships?
|
||||||
$d = 0;
|
$d = 0;
|
||||||
if ($includeCharts) {
|
if ($includeCharts) {
|
||||||
$charts = $pWorksheet->getChartCollection();
|
$charts = $pWorksheet->getChartCollection();
|
||||||
} else {
|
} else {
|
||||||
$charts = array();
|
$charts = array();
|
||||||
}
|
}
|
||||||
if (($pWorksheet->getDrawingCollection()->count() > 0) ||
|
if (($pWorksheet->getDrawingCollection()->count() > 0) ||
|
||||||
(count($charts) > 0)) {
|
(count($charts) > 0)) {
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
++$d,
|
++$d,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing',
|
||||||
'../drawings/drawing' . $pWorksheetId . '.xml'
|
'../drawings/drawing' . $pWorksheetId . '.xml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write chart relationships?
|
// Write chart relationships?
|
||||||
// $chartCount = 0;
|
// $chartCount = 0;
|
||||||
// $charts = $pWorksheet->getChartCollection();
|
// $charts = $pWorksheet->getChartCollection();
|
||||||
// echo 'Chart Rels: ' , count($charts) , '<br />';
|
// echo 'Chart Rels: ' , count($charts) , '<br />';
|
||||||
// if (count($charts) > 0) {
|
// if (count($charts) > 0) {
|
||||||
// foreach($charts as $chart) {
|
// foreach($charts as $chart) {
|
||||||
// $this->_writeRelationship(
|
// $this->_writeRelationship(
|
||||||
// $objWriter,
|
// $objWriter,
|
||||||
// ++$d,
|
// ++$d,
|
||||||
// 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
|
// 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
|
||||||
// '../charts/chart' . ++$chartCount . '.xml'
|
// '../charts/chart' . ++$chartCount . '.xml'
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Write hyperlink relationships?
|
// Write hyperlink relationships?
|
||||||
$i = 1;
|
$i = 1;
|
||||||
foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) {
|
foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) {
|
||||||
if (!$hyperlink->isInternal()) {
|
if (!$hyperlink->isInternal()) {
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
'_hyperlink_' . $i,
|
'_hyperlink_' . $i,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
|
||||||
$hyperlink->getUrl(),
|
$hyperlink->getUrl(),
|
||||||
'External'
|
'External'
|
||||||
);
|
);
|
||||||
|
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write comments relationship?
|
// Write comments relationship?
|
||||||
$i = 1;
|
$i = 1;
|
||||||
if (count($pWorksheet->getComments()) > 0) {
|
if (count($pWorksheet->getComments()) > 0) {
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
'_comments_vml' . $i,
|
'_comments_vml' . $i,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
|
||||||
'../drawings/vmlDrawing' . $pWorksheetId . '.vml'
|
'../drawings/vmlDrawing' . $pWorksheetId . '.vml'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
'_comments' . $i,
|
'_comments' . $i,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments',
|
||||||
'../comments' . $pWorksheetId . '.xml'
|
'../comments' . $pWorksheetId . '.xml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write header/footer relationship?
|
// Write header/footer relationship?
|
||||||
$i = 1;
|
$i = 1;
|
||||||
if (count($pWorksheet->getHeaderFooter()->getImages()) > 0) {
|
if (count($pWorksheet->getHeaderFooter()->getImages()) > 0) {
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
'_headerfooter_vml' . $i,
|
'_headerfooter_vml' . $i,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
|
||||||
'../drawings/vmlDrawingHF' . $pWorksheetId . '.vml'
|
'../drawings/vmlDrawingHF' . $pWorksheetId . '.vml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write drawing relationships to XML format
|
* Write drawing relationships to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Worksheet $pWorksheet
|
* @param PHPExcel_Worksheet $pWorksheet
|
||||||
* @param int &$chartRef Chart ID
|
* @param int &$chartRef Chart ID
|
||||||
* @param boolean $includeCharts Flag indicating if we should write charts
|
* @param boolean $includeCharts Flag indicating if we should write charts
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = FALSE)
|
public function writeDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = FALSE)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Relationships
|
// Relationships
|
||||||
$objWriter->startElement('Relationships');
|
$objWriter->startElement('Relationships');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||||
|
|
||||||
// Loop through images and write relationships
|
// Loop through images and write relationships
|
||||||
$i = 1;
|
$i = 1;
|
||||||
$iterator = $pWorksheet->getDrawingCollection()->getIterator();
|
$iterator = $pWorksheet->getDrawingCollection()->getIterator();
|
||||||
while ($iterator->valid()) {
|
while ($iterator->valid()) {
|
||||||
if ($iterator->current() instanceof PHPExcel_Worksheet_Drawing
|
if ($iterator->current() instanceof PHPExcel_Worksheet_Drawing
|
||||||
|| $iterator->current() instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
|| $iterator->current() instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
||||||
// Write relationship for image drawing
|
// Write relationship for image drawing
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
$i,
|
$i,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
|
||||||
'../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename())
|
'../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$iterator->next();
|
$iterator->next();
|
||||||
++$i;
|
++$i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($includeCharts) {
|
if ($includeCharts) {
|
||||||
// Loop through charts and write relationships
|
// Loop through charts and write relationships
|
||||||
$chartCount = $pWorksheet->getChartCount();
|
$chartCount = $pWorksheet->getChartCount();
|
||||||
if ($chartCount > 0) {
|
if ($chartCount > 0) {
|
||||||
for ($c = 0; $c < $chartCount; ++$c) {
|
for ($c = 0; $c < $chartCount; ++$c) {
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
$i++,
|
$i++,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
|
||||||
'../charts/chart' . ++$chartRef . '.xml'
|
'../charts/chart' . ++$chartRef . '.xml'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write header/footer drawing relationships to XML format
|
* Write header/footer drawing relationships to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Worksheet $pWorksheet
|
* @param PHPExcel_Worksheet $pWorksheet
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeHeaderFooterDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null)
|
public function writeHeaderFooterDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Relationships
|
// Relationships
|
||||||
$objWriter->startElement('Relationships');
|
$objWriter->startElement('Relationships');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||||
|
|
||||||
// Loop through images and write relationships
|
// Loop through images and write relationships
|
||||||
foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) {
|
foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) {
|
||||||
// Write relationship for image drawing
|
// Write relationship for image drawing
|
||||||
$this->_writeRelationship(
|
$this->_writeRelationship(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
$key,
|
$key,
|
||||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
|
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
|
||||||
'../media/' . $value->getIndexedFilename()
|
'../media/' . $value->getIndexedFilename()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Override content type
|
* Write Override content type
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param int $pId Relationship ID. rId will be prepended!
|
* @param int $pId Relationship ID. rId will be prepended!
|
||||||
* @param string $pType Relationship type
|
* @param string $pType Relationship type
|
||||||
* @param string $pTarget Relationship target
|
* @param string $pTarget Relationship target
|
||||||
* @param string $pTargetMode Relationship target mode
|
* @param string $pTargetMode Relationship target mode
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeRelationship(PHPExcel_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
private function _writeRelationship(PHPExcel_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||||
{
|
{
|
||||||
if ($pType != '' && $pTarget != '') {
|
if ($pType != '' && $pTarget != '') {
|
||||||
// Write relationship
|
// Write relationship
|
||||||
$objWriter->startElement('Relationship');
|
$objWriter->startElement('Relationship');
|
||||||
$objWriter->writeAttribute('Id', 'rId' . $pId);
|
$objWriter->writeAttribute('Id', 'rId' . $pId);
|
||||||
$objWriter->writeAttribute('Type', $pType);
|
$objWriter->writeAttribute('Type', $pType);
|
||||||
$objWriter->writeAttribute('Target', $pTarget);
|
$objWriter->writeAttribute('Target', $pTarget);
|
||||||
|
|
||||||
if ($pTargetMode != '') {
|
if ($pTargetMode != '') {
|
||||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel2007
|
* @package PHPExcel_Writer_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,43 +35,43 @@
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_WriterPart
|
class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write relationships for additional objects of custom UI (ribbon)
|
* Write relationships for additional objects of custom UI (ribbon)
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeRibbonRelationships(PHPExcel $pPHPExcel = null){
|
public function writeRibbonRelationships(PHPExcel $pPHPExcel = null){
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Relationships
|
// Relationships
|
||||||
$objWriter->startElement('Relationships');
|
$objWriter->startElement('Relationships');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||||
$localRels=$pPHPExcel->getRibbonBinObjects('names');
|
$localRels=$pPHPExcel->getRibbonBinObjects('names');
|
||||||
if(is_array($localRels)){
|
if(is_array($localRels)){
|
||||||
foreach($localRels as $aId=>$aTarget){
|
foreach($localRels as $aId=>$aTarget){
|
||||||
$objWriter->startElement('Relationship');
|
$objWriter->startElement('Relationship');
|
||||||
$objWriter->writeAttribute('Id', $aId);
|
$objWriter->writeAttribute('Id', $aId);
|
||||||
$objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image');
|
$objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image');
|
||||||
$objWriter->writeAttribute('Target', $aTarget);
|
$objWriter->writeAttribute('Target', $aTarget);
|
||||||
$objWriter->endElement();//Relationship
|
$objWriter->endElement();//Relationship
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$objWriter->endElement();//Relationships
|
$objWriter->endElement();//Relationships
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel2007
|
* @package PHPExcel_Writer_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,38 +35,38 @@
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Writer_Excel2007_RelsVBA extends PHPExcel_Writer_Excel2007_WriterPart
|
class PHPExcel_Writer_Excel2007_RelsVBA extends PHPExcel_Writer_Excel2007_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write relationships for a signed VBA Project
|
* Write relationships for a signed VBA Project
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeVBARelationships(PHPExcel $pPHPExcel = null){
|
public function writeVBARelationships(PHPExcel $pPHPExcel = null){
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// Relationships
|
// Relationships
|
||||||
$objWriter->startElement('Relationships');
|
$objWriter->startElement('Relationships');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||||
$objWriter->startElement('Relationship');
|
$objWriter->startElement('Relationship');
|
||||||
$objWriter->writeAttribute('Id', 'rId1');
|
$objWriter->writeAttribute('Id', 'rId1');
|
||||||
$objWriter->writeAttribute('Type', 'http://schemas.microsoft.com/office/2006/relationships/vbaProjectSignature');
|
$objWriter->writeAttribute('Type', 'http://schemas.microsoft.com/office/2006/relationships/vbaProjectSignature');
|
||||||
$objWriter->writeAttribute('Target', 'vbaProjectSignature.bin');
|
$objWriter->writeAttribute('Target', 'vbaProjectSignature.bin');
|
||||||
$objWriter->endElement();//Relationship
|
$objWriter->endElement();//Relationship
|
||||||
$objWriter->endElement();//Relationships
|
$objWriter->endElement();//Relationships
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel2007
|
* @package PHPExcel_Writer_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,285 +35,285 @@
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_WriterPart
|
class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Create worksheet stringtable
|
* Create worksheet stringtable
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Worksheet $pSheet Worksheet
|
* @param PHPExcel_Worksheet $pSheet Worksheet
|
||||||
* @param string[] $pExistingTable Existing table to eventually merge with
|
* @param string[] $pExistingTable Existing table to eventually merge with
|
||||||
* @return string[] String table for worksheet
|
* @return string[] String table for worksheet
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function createStringTable($pSheet = null, $pExistingTable = null)
|
public function createStringTable($pSheet = null, $pExistingTable = null)
|
||||||
{
|
{
|
||||||
if ($pSheet !== NULL) {
|
if ($pSheet !== NULL) {
|
||||||
// Create string lookup table
|
// Create string lookup table
|
||||||
$aStringTable = array();
|
$aStringTable = array();
|
||||||
$cellCollection = null;
|
$cellCollection = null;
|
||||||
$aFlippedStringTable = null; // For faster lookup
|
$aFlippedStringTable = null; // For faster lookup
|
||||||
|
|
||||||
// Is an existing table given?
|
// Is an existing table given?
|
||||||
if (($pExistingTable !== NULL) && is_array($pExistingTable)) {
|
if (($pExistingTable !== NULL) && is_array($pExistingTable)) {
|
||||||
$aStringTable = $pExistingTable;
|
$aStringTable = $pExistingTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill index array
|
// Fill index array
|
||||||
$aFlippedStringTable = $this->flipStringTable($aStringTable);
|
$aFlippedStringTable = $this->flipStringTable($aStringTable);
|
||||||
|
|
||||||
// Loop through cells
|
// Loop through cells
|
||||||
foreach ($pSheet->getCellCollection() as $cellID) {
|
foreach ($pSheet->getCellCollection() as $cellID) {
|
||||||
$cell = $pSheet->getCell($cellID);
|
$cell = $pSheet->getCell($cellID);
|
||||||
$cellValue = $cell->getValue();
|
$cellValue = $cell->getValue();
|
||||||
if (!is_object($cellValue) &&
|
if (!is_object($cellValue) &&
|
||||||
($cellValue !== NULL) &&
|
($cellValue !== NULL) &&
|
||||||
$cellValue !== '' &&
|
$cellValue !== '' &&
|
||||||
!isset($aFlippedStringTable[$cellValue]) &&
|
!isset($aFlippedStringTable[$cellValue]) &&
|
||||||
($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING2 || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL)) {
|
($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_STRING2 || $cell->getDataType() == PHPExcel_Cell_DataType::TYPE_NULL)) {
|
||||||
$aStringTable[] = $cellValue;
|
$aStringTable[] = $cellValue;
|
||||||
$aFlippedStringTable[$cellValue] = true;
|
$aFlippedStringTable[$cellValue] = true;
|
||||||
} elseif ($cellValue instanceof PHPExcel_RichText &&
|
} elseif ($cellValue instanceof PHPExcel_RichText &&
|
||||||
($cellValue !== NULL) &&
|
($cellValue !== NULL) &&
|
||||||
!isset($aFlippedStringTable[$cellValue->getHashCode()])) {
|
!isset($aFlippedStringTable[$cellValue->getHashCode()])) {
|
||||||
$aStringTable[] = $cellValue;
|
$aStringTable[] = $cellValue;
|
||||||
$aFlippedStringTable[$cellValue->getHashCode()] = true;
|
$aFlippedStringTable[$cellValue->getHashCode()] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $aStringTable;
|
return $aStringTable;
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("Invalid PHPExcel_Worksheet object passed.");
|
throw new PHPExcel_Writer_Exception("Invalid PHPExcel_Worksheet object passed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write string table to XML format
|
* Write string table to XML format
|
||||||
*
|
*
|
||||||
* @param string[] $pStringTable
|
* @param string[] $pStringTable
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeStringTable($pStringTable = null)
|
public function writeStringTable($pStringTable = null)
|
||||||
{
|
{
|
||||||
if ($pStringTable !== NULL) {
|
if ($pStringTable !== NULL) {
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// String table
|
// String table
|
||||||
$objWriter->startElement('sst');
|
$objWriter->startElement('sst');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
||||||
$objWriter->writeAttribute('uniqueCount', count($pStringTable));
|
$objWriter->writeAttribute('uniqueCount', count($pStringTable));
|
||||||
|
|
||||||
// Loop through string table
|
// Loop through string table
|
||||||
foreach ($pStringTable as $textElement) {
|
foreach ($pStringTable as $textElement) {
|
||||||
$objWriter->startElement('si');
|
$objWriter->startElement('si');
|
||||||
|
|
||||||
if (! $textElement instanceof PHPExcel_RichText) {
|
if (! $textElement instanceof PHPExcel_RichText) {
|
||||||
$textToWrite = PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $textElement );
|
$textToWrite = PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $textElement );
|
||||||
$objWriter->startElement('t');
|
$objWriter->startElement('t');
|
||||||
if ($textToWrite !== trim($textToWrite)) {
|
if ($textToWrite !== trim($textToWrite)) {
|
||||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||||
}
|
}
|
||||||
$objWriter->writeRawData($textToWrite);
|
$objWriter->writeRawData($textToWrite);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
} else if ($textElement instanceof PHPExcel_RichText) {
|
} else if ($textElement instanceof PHPExcel_RichText) {
|
||||||
$this->writeRichText($objWriter, $textElement);
|
$this->writeRichText($objWriter, $textElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("Invalid string table array passed.");
|
throw new PHPExcel_Writer_Exception("Invalid string table array passed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Rich Text
|
* Write Rich Text
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param PHPExcel_RichText $pRichText Rich text
|
* @param PHPExcel_RichText $pRichText Rich text
|
||||||
* @param string $prefix Optional Namespace prefix
|
* @param string $prefix Optional Namespace prefix
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null, $prefix=NULL)
|
public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null, $prefix=NULL)
|
||||||
{
|
{
|
||||||
if ($prefix !== NULL)
|
if ($prefix !== NULL)
|
||||||
$prefix .= ':';
|
$prefix .= ':';
|
||||||
// Loop through rich text elements
|
// Loop through rich text elements
|
||||||
$elements = $pRichText->getRichTextElements();
|
$elements = $pRichText->getRichTextElements();
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
// r
|
// r
|
||||||
$objWriter->startElement($prefix.'r');
|
$objWriter->startElement($prefix.'r');
|
||||||
|
|
||||||
// rPr
|
// rPr
|
||||||
if ($element instanceof PHPExcel_RichText_Run) {
|
if ($element instanceof PHPExcel_RichText_Run) {
|
||||||
// rPr
|
// rPr
|
||||||
$objWriter->startElement($prefix.'rPr');
|
$objWriter->startElement($prefix.'rPr');
|
||||||
|
|
||||||
// rFont
|
// rFont
|
||||||
$objWriter->startElement($prefix.'rFont');
|
$objWriter->startElement($prefix.'rFont');
|
||||||
$objWriter->writeAttribute('val', $element->getFont()->getName());
|
$objWriter->writeAttribute('val', $element->getFont()->getName());
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Bold
|
// Bold
|
||||||
$objWriter->startElement($prefix.'b');
|
$objWriter->startElement($prefix.'b');
|
||||||
$objWriter->writeAttribute('val', ($element->getFont()->getBold() ? 'true' : 'false'));
|
$objWriter->writeAttribute('val', ($element->getFont()->getBold() ? 'true' : 'false'));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Italic
|
// Italic
|
||||||
$objWriter->startElement($prefix.'i');
|
$objWriter->startElement($prefix.'i');
|
||||||
$objWriter->writeAttribute('val', ($element->getFont()->getItalic() ? 'true' : 'false'));
|
$objWriter->writeAttribute('val', ($element->getFont()->getItalic() ? 'true' : 'false'));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Superscript / subscript
|
// Superscript / subscript
|
||||||
if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
|
if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
|
||||||
$objWriter->startElement($prefix.'vertAlign');
|
$objWriter->startElement($prefix.'vertAlign');
|
||||||
if ($element->getFont()->getSuperScript()) {
|
if ($element->getFont()->getSuperScript()) {
|
||||||
$objWriter->writeAttribute('val', 'superscript');
|
$objWriter->writeAttribute('val', 'superscript');
|
||||||
} else if ($element->getFont()->getSubScript()) {
|
} else if ($element->getFont()->getSubScript()) {
|
||||||
$objWriter->writeAttribute('val', 'subscript');
|
$objWriter->writeAttribute('val', 'subscript');
|
||||||
}
|
}
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strikethrough
|
// Strikethrough
|
||||||
$objWriter->startElement($prefix.'strike');
|
$objWriter->startElement($prefix.'strike');
|
||||||
$objWriter->writeAttribute('val', ($element->getFont()->getStrikethrough() ? 'true' : 'false'));
|
$objWriter->writeAttribute('val', ($element->getFont()->getStrikethrough() ? 'true' : 'false'));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
$objWriter->startElement($prefix.'color');
|
$objWriter->startElement($prefix.'color');
|
||||||
$objWriter->writeAttribute('rgb', $element->getFont()->getColor()->getARGB());
|
$objWriter->writeAttribute('rgb', $element->getFont()->getColor()->getARGB());
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Size
|
// Size
|
||||||
$objWriter->startElement($prefix.'sz');
|
$objWriter->startElement($prefix.'sz');
|
||||||
$objWriter->writeAttribute('val', $element->getFont()->getSize());
|
$objWriter->writeAttribute('val', $element->getFont()->getSize());
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Underline
|
// Underline
|
||||||
$objWriter->startElement($prefix.'u');
|
$objWriter->startElement($prefix.'u');
|
||||||
$objWriter->writeAttribute('val', $element->getFont()->getUnderline());
|
$objWriter->writeAttribute('val', $element->getFont()->getUnderline());
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
// t
|
// t
|
||||||
$objWriter->startElement($prefix.'t');
|
$objWriter->startElement($prefix.'t');
|
||||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||||
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
|
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Rich Text
|
* Write Rich Text
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param string|PHPExcel_RichText $pRichText text string or Rich text
|
* @param string|PHPExcel_RichText $pRichText text string or Rich text
|
||||||
* @param string $prefix Optional Namespace prefix
|
* @param string $prefix Optional Namespace prefix
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix=NULL)
|
public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix=NULL)
|
||||||
{
|
{
|
||||||
if (!$pRichText instanceof PHPExcel_RichText) {
|
if (!$pRichText instanceof PHPExcel_RichText) {
|
||||||
$textRun = $pRichText;
|
$textRun = $pRichText;
|
||||||
$pRichText = new PHPExcel_RichText();
|
$pRichText = new PHPExcel_RichText();
|
||||||
$pRichText->createTextRun($textRun);
|
$pRichText->createTextRun($textRun);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($prefix !== NULL)
|
if ($prefix !== NULL)
|
||||||
$prefix .= ':';
|
$prefix .= ':';
|
||||||
// Loop through rich text elements
|
// Loop through rich text elements
|
||||||
$elements = $pRichText->getRichTextElements();
|
$elements = $pRichText->getRichTextElements();
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
// r
|
// r
|
||||||
$objWriter->startElement($prefix.'r');
|
$objWriter->startElement($prefix.'r');
|
||||||
|
|
||||||
// rPr
|
// rPr
|
||||||
$objWriter->startElement($prefix.'rPr');
|
$objWriter->startElement($prefix.'rPr');
|
||||||
|
|
||||||
// Bold
|
// Bold
|
||||||
$objWriter->writeAttribute('b', ($element->getFont()->getBold() ? 1 : 0));
|
$objWriter->writeAttribute('b', ($element->getFont()->getBold() ? 1 : 0));
|
||||||
// Italic
|
// Italic
|
||||||
$objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 1 : 0));
|
$objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 1 : 0));
|
||||||
// Underline
|
// Underline
|
||||||
$underlineType = $element->getFont()->getUnderline();
|
$underlineType = $element->getFont()->getUnderline();
|
||||||
switch($underlineType) {
|
switch($underlineType) {
|
||||||
case 'single' :
|
case 'single' :
|
||||||
$underlineType = 'sng';
|
$underlineType = 'sng';
|
||||||
break;
|
break;
|
||||||
case 'double' :
|
case 'double' :
|
||||||
$underlineType = 'dbl';
|
$underlineType = 'dbl';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$objWriter->writeAttribute('u', $underlineType);
|
$objWriter->writeAttribute('u', $underlineType);
|
||||||
// Strikethrough
|
// Strikethrough
|
||||||
$objWriter->writeAttribute('strike', ($element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike'));
|
$objWriter->writeAttribute('strike', ($element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike'));
|
||||||
|
|
||||||
// rFont
|
// rFont
|
||||||
$objWriter->startElement($prefix.'latin');
|
$objWriter->startElement($prefix.'latin');
|
||||||
$objWriter->writeAttribute('typeface', $element->getFont()->getName());
|
$objWriter->writeAttribute('typeface', $element->getFont()->getName());
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Superscript / subscript
|
// Superscript / subscript
|
||||||
// if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
|
// if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
|
||||||
// $objWriter->startElement($prefix.'vertAlign');
|
// $objWriter->startElement($prefix.'vertAlign');
|
||||||
// if ($element->getFont()->getSuperScript()) {
|
// if ($element->getFont()->getSuperScript()) {
|
||||||
// $objWriter->writeAttribute('val', 'superscript');
|
// $objWriter->writeAttribute('val', 'superscript');
|
||||||
// } else if ($element->getFont()->getSubScript()) {
|
// } else if ($element->getFont()->getSubScript()) {
|
||||||
// $objWriter->writeAttribute('val', 'subscript');
|
// $objWriter->writeAttribute('val', 'subscript');
|
||||||
// }
|
// }
|
||||||
// $objWriter->endElement();
|
// $objWriter->endElement();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// t
|
// t
|
||||||
$objWriter->startElement($prefix.'t');
|
$objWriter->startElement($prefix.'t');
|
||||||
// $objWriter->writeAttribute('xml:space', 'preserve'); // Excel2010 accepts, Excel2007 complains
|
// $objWriter->writeAttribute('xml:space', 'preserve'); // Excel2010 accepts, Excel2007 complains
|
||||||
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
|
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flip string table (for index searching)
|
* Flip string table (for index searching)
|
||||||
*
|
*
|
||||||
* @param array $stringTable Stringtable
|
* @param array $stringTable Stringtable
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function flipStringTable($stringTable = array()) {
|
public function flipStringTable($stringTable = array()) {
|
||||||
// Return value
|
// Return value
|
||||||
$returnValue = array();
|
$returnValue = array();
|
||||||
|
|
||||||
// Loop through stringtable and add flipped items to $returnValue
|
// Loop through stringtable and add flipped items to $returnValue
|
||||||
foreach ($stringTable as $key => $value) {
|
foreach ($stringTable as $key => $value) {
|
||||||
if (! $value instanceof PHPExcel_RichText) {
|
if (! $value instanceof PHPExcel_RichText) {
|
||||||
$returnValue[$value] = $key;
|
$returnValue[$value] = $key;
|
||||||
} else if ($value instanceof PHPExcel_RichText) {
|
} else if ($value instanceof PHPExcel_RichText) {
|
||||||
$returnValue[$value->getHashCode()] = $key;
|
$returnValue[$value->getHashCode()] = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $returnValue;
|
return $returnValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel2007
|
* @package PHPExcel_Writer_Excel2007
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,422 +35,422 @@
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_WriterPart
|
class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write workbook to XML format
|
* Write workbook to XML format
|
||||||
*
|
*
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing
|
* @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing
|
||||||
* @return string XML Output
|
* @return string XML Output
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function writeWorkbook(PHPExcel $pPHPExcel = null, $recalcRequired = FALSE)
|
public function writeWorkbook(PHPExcel $pPHPExcel = null, $recalcRequired = FALSE)
|
||||||
{
|
{
|
||||||
// Create XML writer
|
// Create XML writer
|
||||||
$objWriter = null;
|
$objWriter = null;
|
||||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||||
} else {
|
} else {
|
||||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XML header
|
// XML header
|
||||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||||
|
|
||||||
// workbook
|
// workbook
|
||||||
$objWriter->startElement('workbook');
|
$objWriter->startElement('workbook');
|
||||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
||||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||||
|
|
||||||
// fileVersion
|
// fileVersion
|
||||||
$this->_writeFileVersion($objWriter);
|
$this->_writeFileVersion($objWriter);
|
||||||
|
|
||||||
// workbookPr
|
// workbookPr
|
||||||
$this->_writeWorkbookPr($objWriter);
|
$this->_writeWorkbookPr($objWriter);
|
||||||
|
|
||||||
// workbookProtection
|
// workbookProtection
|
||||||
$this->_writeWorkbookProtection($objWriter, $pPHPExcel);
|
$this->_writeWorkbookProtection($objWriter, $pPHPExcel);
|
||||||
|
|
||||||
// bookViews
|
// bookViews
|
||||||
if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
|
if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
|
||||||
$this->_writeBookViews($objWriter, $pPHPExcel);
|
$this->_writeBookViews($objWriter, $pPHPExcel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sheets
|
// sheets
|
||||||
$this->_writeSheets($objWriter, $pPHPExcel);
|
$this->_writeSheets($objWriter, $pPHPExcel);
|
||||||
|
|
||||||
// definedNames
|
// definedNames
|
||||||
$this->_writeDefinedNames($objWriter, $pPHPExcel);
|
$this->_writeDefinedNames($objWriter, $pPHPExcel);
|
||||||
|
|
||||||
// calcPr
|
// calcPr
|
||||||
$this->_writeCalcPr($objWriter,$recalcRequired);
|
$this->_writeCalcPr($objWriter,$recalcRequired);
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write file version
|
* Write file version
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeFileVersion(PHPExcel_Shared_XMLWriter $objWriter = null)
|
private function _writeFileVersion(PHPExcel_Shared_XMLWriter $objWriter = null)
|
||||||
{
|
{
|
||||||
$objWriter->startElement('fileVersion');
|
$objWriter->startElement('fileVersion');
|
||||||
$objWriter->writeAttribute('appName', 'xl');
|
$objWriter->writeAttribute('appName', 'xl');
|
||||||
$objWriter->writeAttribute('lastEdited', '4');
|
$objWriter->writeAttribute('lastEdited', '4');
|
||||||
$objWriter->writeAttribute('lowestEdited', '4');
|
$objWriter->writeAttribute('lowestEdited', '4');
|
||||||
$objWriter->writeAttribute('rupBuild', '4505');
|
$objWriter->writeAttribute('rupBuild', '4505');
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write WorkbookPr
|
* Write WorkbookPr
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeWorkbookPr(PHPExcel_Shared_XMLWriter $objWriter = null)
|
private function _writeWorkbookPr(PHPExcel_Shared_XMLWriter $objWriter = null)
|
||||||
{
|
{
|
||||||
$objWriter->startElement('workbookPr');
|
$objWriter->startElement('workbookPr');
|
||||||
|
|
||||||
if (PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904) {
|
if (PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904) {
|
||||||
$objWriter->writeAttribute('date1904', '1');
|
$objWriter->writeAttribute('date1904', '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->writeAttribute('codeName', 'ThisWorkbook');
|
$objWriter->writeAttribute('codeName', 'ThisWorkbook');
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write BookViews
|
* Write BookViews
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeBookViews(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
private function _writeBookViews(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
// bookViews
|
// bookViews
|
||||||
$objWriter->startElement('bookViews');
|
$objWriter->startElement('bookViews');
|
||||||
|
|
||||||
// workbookView
|
// workbookView
|
||||||
$objWriter->startElement('workbookView');
|
$objWriter->startElement('workbookView');
|
||||||
|
|
||||||
$objWriter->writeAttribute('activeTab', $pPHPExcel->getActiveSheetIndex());
|
$objWriter->writeAttribute('activeTab', $pPHPExcel->getActiveSheetIndex());
|
||||||
$objWriter->writeAttribute('autoFilterDateGrouping', '1');
|
$objWriter->writeAttribute('autoFilterDateGrouping', '1');
|
||||||
$objWriter->writeAttribute('firstSheet', '0');
|
$objWriter->writeAttribute('firstSheet', '0');
|
||||||
$objWriter->writeAttribute('minimized', '0');
|
$objWriter->writeAttribute('minimized', '0');
|
||||||
$objWriter->writeAttribute('showHorizontalScroll', '1');
|
$objWriter->writeAttribute('showHorizontalScroll', '1');
|
||||||
$objWriter->writeAttribute('showSheetTabs', '1');
|
$objWriter->writeAttribute('showSheetTabs', '1');
|
||||||
$objWriter->writeAttribute('showVerticalScroll', '1');
|
$objWriter->writeAttribute('showVerticalScroll', '1');
|
||||||
$objWriter->writeAttribute('tabRatio', '600');
|
$objWriter->writeAttribute('tabRatio', '600');
|
||||||
$objWriter->writeAttribute('visibility', 'visible');
|
$objWriter->writeAttribute('visibility', 'visible');
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write WorkbookProtection
|
* Write WorkbookProtection
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeWorkbookProtection(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
private function _writeWorkbookProtection(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
if ($pPHPExcel->getSecurity()->isSecurityEnabled()) {
|
if ($pPHPExcel->getSecurity()->isSecurityEnabled()) {
|
||||||
$objWriter->startElement('workbookProtection');
|
$objWriter->startElement('workbookProtection');
|
||||||
$objWriter->writeAttribute('lockRevision', ($pPHPExcel->getSecurity()->getLockRevision() ? 'true' : 'false'));
|
$objWriter->writeAttribute('lockRevision', ($pPHPExcel->getSecurity()->getLockRevision() ? 'true' : 'false'));
|
||||||
$objWriter->writeAttribute('lockStructure', ($pPHPExcel->getSecurity()->getLockStructure() ? 'true' : 'false'));
|
$objWriter->writeAttribute('lockStructure', ($pPHPExcel->getSecurity()->getLockStructure() ? 'true' : 'false'));
|
||||||
$objWriter->writeAttribute('lockWindows', ($pPHPExcel->getSecurity()->getLockWindows() ? 'true' : 'false'));
|
$objWriter->writeAttribute('lockWindows', ($pPHPExcel->getSecurity()->getLockWindows() ? 'true' : 'false'));
|
||||||
|
|
||||||
if ($pPHPExcel->getSecurity()->getRevisionsPassword() != '') {
|
if ($pPHPExcel->getSecurity()->getRevisionsPassword() != '') {
|
||||||
$objWriter->writeAttribute('revisionsPassword', $pPHPExcel->getSecurity()->getRevisionsPassword());
|
$objWriter->writeAttribute('revisionsPassword', $pPHPExcel->getSecurity()->getRevisionsPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($pPHPExcel->getSecurity()->getWorkbookPassword() != '') {
|
if ($pPHPExcel->getSecurity()->getWorkbookPassword() != '') {
|
||||||
$objWriter->writeAttribute('workbookPassword', $pPHPExcel->getSecurity()->getWorkbookPassword());
|
$objWriter->writeAttribute('workbookPassword', $pPHPExcel->getSecurity()->getWorkbookPassword());
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write calcPr
|
* Write calcPr
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing
|
* @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeCalcPr(PHPExcel_Shared_XMLWriter $objWriter = null, $recalcRequired = TRUE)
|
private function _writeCalcPr(PHPExcel_Shared_XMLWriter $objWriter = null, $recalcRequired = TRUE)
|
||||||
{
|
{
|
||||||
$objWriter->startElement('calcPr');
|
$objWriter->startElement('calcPr');
|
||||||
|
|
||||||
// Set the calcid to a higher value than Excel itself will use, otherwise Excel will always recalc
|
// Set the calcid to a higher value than Excel itself will use, otherwise Excel will always recalc
|
||||||
// If MS Excel does do a recalc, then users opening a file in MS Excel will be prompted to save on exit
|
// If MS Excel does do a recalc, then users opening a file in MS Excel will be prompted to save on exit
|
||||||
// because the file has changed
|
// because the file has changed
|
||||||
$objWriter->writeAttribute('calcId', '999999');
|
$objWriter->writeAttribute('calcId', '999999');
|
||||||
$objWriter->writeAttribute('calcMode', 'auto');
|
$objWriter->writeAttribute('calcMode', 'auto');
|
||||||
// fullCalcOnLoad isn't needed if we've recalculating for the save
|
// fullCalcOnLoad isn't needed if we've recalculating for the save
|
||||||
$objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? 1 : 0);
|
$objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? 1 : 0);
|
||||||
$objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? 0 : 1);
|
$objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? 0 : 1);
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write sheets
|
* Write sheets
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeSheets(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
private function _writeSheets(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
// Write sheets
|
// Write sheets
|
||||||
$objWriter->startElement('sheets');
|
$objWriter->startElement('sheets');
|
||||||
$sheetCount = $pPHPExcel->getSheetCount();
|
$sheetCount = $pPHPExcel->getSheetCount();
|
||||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||||
// sheet
|
// sheet
|
||||||
$this->_writeSheet(
|
$this->_writeSheet(
|
||||||
$objWriter,
|
$objWriter,
|
||||||
$pPHPExcel->getSheet($i)->getTitle(),
|
$pPHPExcel->getSheet($i)->getTitle(),
|
||||||
($i + 1),
|
($i + 1),
|
||||||
($i + 1 + 3),
|
($i + 1 + 3),
|
||||||
$pPHPExcel->getSheet($i)->getSheetState()
|
$pPHPExcel->getSheet($i)->getSheetState()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write sheet
|
* Write sheet
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param string $pSheetname Sheet name
|
* @param string $pSheetname Sheet name
|
||||||
* @param int $pSheetId Sheet id
|
* @param int $pSheetId Sheet id
|
||||||
* @param int $pRelId Relationship ID
|
* @param int $pRelId Relationship ID
|
||||||
* @param string $sheetState Sheet state (visible, hidden, veryHidden)
|
* @param string $sheetState Sheet state (visible, hidden, veryHidden)
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeSheet(PHPExcel_Shared_XMLWriter $objWriter = null, $pSheetname = '', $pSheetId = 1, $pRelId = 1, $sheetState = 'visible')
|
private function _writeSheet(PHPExcel_Shared_XMLWriter $objWriter = null, $pSheetname = '', $pSheetId = 1, $pRelId = 1, $sheetState = 'visible')
|
||||||
{
|
{
|
||||||
if ($pSheetname != '') {
|
if ($pSheetname != '') {
|
||||||
// Write sheet
|
// Write sheet
|
||||||
$objWriter->startElement('sheet');
|
$objWriter->startElement('sheet');
|
||||||
$objWriter->writeAttribute('name', $pSheetname);
|
$objWriter->writeAttribute('name', $pSheetname);
|
||||||
$objWriter->writeAttribute('sheetId', $pSheetId);
|
$objWriter->writeAttribute('sheetId', $pSheetId);
|
||||||
if ($sheetState != 'visible' && $sheetState != '') {
|
if ($sheetState != 'visible' && $sheetState != '') {
|
||||||
$objWriter->writeAttribute('state', $sheetState);
|
$objWriter->writeAttribute('state', $sheetState);
|
||||||
}
|
}
|
||||||
$objWriter->writeAttribute('r:id', 'rId' . $pRelId);
|
$objWriter->writeAttribute('r:id', 'rId' . $pRelId);
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Defined Names
|
* Write Defined Names
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeDefinedNames(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
private function _writeDefinedNames(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
// Write defined names
|
// Write defined names
|
||||||
$objWriter->startElement('definedNames');
|
$objWriter->startElement('definedNames');
|
||||||
|
|
||||||
// Named ranges
|
// Named ranges
|
||||||
if (count($pPHPExcel->getNamedRanges()) > 0) {
|
if (count($pPHPExcel->getNamedRanges()) > 0) {
|
||||||
// Named ranges
|
// Named ranges
|
||||||
$this->_writeNamedRanges($objWriter, $pPHPExcel);
|
$this->_writeNamedRanges($objWriter, $pPHPExcel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other defined names
|
// Other defined names
|
||||||
$sheetCount = $pPHPExcel->getSheetCount();
|
$sheetCount = $pPHPExcel->getSheetCount();
|
||||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||||
// definedName for autoFilter
|
// definedName for autoFilter
|
||||||
$this->_writeDefinedNameForAutofilter($objWriter, $pPHPExcel->getSheet($i), $i);
|
$this->_writeDefinedNameForAutofilter($objWriter, $pPHPExcel->getSheet($i), $i);
|
||||||
|
|
||||||
// definedName for Print_Titles
|
// definedName for Print_Titles
|
||||||
$this->_writeDefinedNameForPrintTitles($objWriter, $pPHPExcel->getSheet($i), $i);
|
$this->_writeDefinedNameForPrintTitles($objWriter, $pPHPExcel->getSheet($i), $i);
|
||||||
|
|
||||||
// definedName for Print_Area
|
// definedName for Print_Area
|
||||||
$this->_writeDefinedNameForPrintArea($objWriter, $pPHPExcel->getSheet($i), $i);
|
$this->_writeDefinedNameForPrintArea($objWriter, $pPHPExcel->getSheet($i), $i);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write named ranges
|
* Write named ranges
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param PHPExcel $pPHPExcel
|
* @param PHPExcel $pPHPExcel
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeNamedRanges(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel)
|
private function _writeNamedRanges(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel)
|
||||||
{
|
{
|
||||||
// Loop named ranges
|
// Loop named ranges
|
||||||
$namedRanges = $pPHPExcel->getNamedRanges();
|
$namedRanges = $pPHPExcel->getNamedRanges();
|
||||||
foreach ($namedRanges as $namedRange) {
|
foreach ($namedRanges as $namedRange) {
|
||||||
$this->_writeDefinedNameForNamedRange($objWriter, $namedRange);
|
$this->_writeDefinedNameForNamedRange($objWriter, $namedRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Defined Name for named range
|
* Write Defined Name for named range
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param PHPExcel_NamedRange $pNamedRange
|
* @param PHPExcel_NamedRange $pNamedRange
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeDefinedNameForNamedRange(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_NamedRange $pNamedRange)
|
private function _writeDefinedNameForNamedRange(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_NamedRange $pNamedRange)
|
||||||
{
|
{
|
||||||
// definedName for named range
|
// definedName for named range
|
||||||
$objWriter->startElement('definedName');
|
$objWriter->startElement('definedName');
|
||||||
$objWriter->writeAttribute('name', $pNamedRange->getName());
|
$objWriter->writeAttribute('name', $pNamedRange->getName());
|
||||||
if ($pNamedRange->getLocalOnly()) {
|
if ($pNamedRange->getLocalOnly()) {
|
||||||
$objWriter->writeAttribute('localSheetId', $pNamedRange->getScope()->getParent()->getIndex($pNamedRange->getScope()));
|
$objWriter->writeAttribute('localSheetId', $pNamedRange->getScope()->getParent()->getIndex($pNamedRange->getScope()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create absolute coordinate and write as raw text
|
// Create absolute coordinate and write as raw text
|
||||||
$range = PHPExcel_Cell::splitRange($pNamedRange->getRange());
|
$range = PHPExcel_Cell::splitRange($pNamedRange->getRange());
|
||||||
for ($i = 0; $i < count($range); $i++) {
|
for ($i = 0; $i < count($range); $i++) {
|
||||||
$range[$i][0] = '\'' . str_replace("'", "''", $pNamedRange->getWorksheet()->getTitle()) . '\'!' . PHPExcel_Cell::absoluteReference($range[$i][0]);
|
$range[$i][0] = '\'' . str_replace("'", "''", $pNamedRange->getWorksheet()->getTitle()) . '\'!' . PHPExcel_Cell::absoluteReference($range[$i][0]);
|
||||||
if (isset($range[$i][1])) {
|
if (isset($range[$i][1])) {
|
||||||
$range[$i][1] = PHPExcel_Cell::absoluteReference($range[$i][1]);
|
$range[$i][1] = PHPExcel_Cell::absoluteReference($range[$i][1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$range = PHPExcel_Cell::buildRange($range);
|
$range = PHPExcel_Cell::buildRange($range);
|
||||||
|
|
||||||
$objWriter->writeRawData($range);
|
$objWriter->writeRawData($range);
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Defined Name for autoFilter
|
* Write Defined Name for autoFilter
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param PHPExcel_Worksheet $pSheet
|
* @param PHPExcel_Worksheet $pSheet
|
||||||
* @param int $pSheetId
|
* @param int $pSheetId
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeDefinedNameForAutofilter(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
|
private function _writeDefinedNameForAutofilter(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
|
||||||
{
|
{
|
||||||
// definedName for autoFilter
|
// definedName for autoFilter
|
||||||
$autoFilterRange = $pSheet->getAutoFilter()->getRange();
|
$autoFilterRange = $pSheet->getAutoFilter()->getRange();
|
||||||
if (!empty($autoFilterRange)) {
|
if (!empty($autoFilterRange)) {
|
||||||
$objWriter->startElement('definedName');
|
$objWriter->startElement('definedName');
|
||||||
$objWriter->writeAttribute('name', '_xlnm._FilterDatabase');
|
$objWriter->writeAttribute('name', '_xlnm._FilterDatabase');
|
||||||
$objWriter->writeAttribute('localSheetId', $pSheetId);
|
$objWriter->writeAttribute('localSheetId', $pSheetId);
|
||||||
$objWriter->writeAttribute('hidden', '1');
|
$objWriter->writeAttribute('hidden', '1');
|
||||||
|
|
||||||
// Create absolute coordinate and write as raw text
|
// Create absolute coordinate and write as raw text
|
||||||
$range = PHPExcel_Cell::splitRange($autoFilterRange);
|
$range = PHPExcel_Cell::splitRange($autoFilterRange);
|
||||||
$range = $range[0];
|
$range = $range[0];
|
||||||
// Strip any worksheet ref so we can make the cell ref absolute
|
// Strip any worksheet ref so we can make the cell ref absolute
|
||||||
if (strpos($range[0],'!') !== false) {
|
if (strpos($range[0],'!') !== false) {
|
||||||
list($ws,$range[0]) = explode('!',$range[0]);
|
list($ws,$range[0]) = explode('!',$range[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$range[0] = PHPExcel_Cell::absoluteCoordinate($range[0]);
|
$range[0] = PHPExcel_Cell::absoluteCoordinate($range[0]);
|
||||||
$range[1] = PHPExcel_Cell::absoluteCoordinate($range[1]);
|
$range[1] = PHPExcel_Cell::absoluteCoordinate($range[1]);
|
||||||
$range = implode(':', $range);
|
$range = implode(':', $range);
|
||||||
|
|
||||||
$objWriter->writeRawData('\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . $range);
|
$objWriter->writeRawData('\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . $range);
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Defined Name for PrintTitles
|
* Write Defined Name for PrintTitles
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param PHPExcel_Worksheet $pSheet
|
* @param PHPExcel_Worksheet $pSheet
|
||||||
* @param int $pSheetId
|
* @param int $pSheetId
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeDefinedNameForPrintTitles(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
|
private function _writeDefinedNameForPrintTitles(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
|
||||||
{
|
{
|
||||||
// definedName for PrintTitles
|
// definedName for PrintTitles
|
||||||
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
|
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
|
||||||
$objWriter->startElement('definedName');
|
$objWriter->startElement('definedName');
|
||||||
$objWriter->writeAttribute('name', '_xlnm.Print_Titles');
|
$objWriter->writeAttribute('name', '_xlnm.Print_Titles');
|
||||||
$objWriter->writeAttribute('localSheetId', $pSheetId);
|
$objWriter->writeAttribute('localSheetId', $pSheetId);
|
||||||
|
|
||||||
// Setting string
|
// Setting string
|
||||||
$settingString = '';
|
$settingString = '';
|
||||||
|
|
||||||
// Columns to repeat
|
// Columns to repeat
|
||||||
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet()) {
|
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet()) {
|
||||||
$repeat = $pSheet->getPageSetup()->getColumnsToRepeatAtLeft();
|
$repeat = $pSheet->getPageSetup()->getColumnsToRepeatAtLeft();
|
||||||
|
|
||||||
$settingString .= '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!$' . $repeat[0] . ':$' . $repeat[1];
|
$settingString .= '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!$' . $repeat[0] . ':$' . $repeat[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rows to repeat
|
// Rows to repeat
|
||||||
if ($pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
|
if ($pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
|
||||||
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet()) {
|
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet()) {
|
||||||
$settingString .= ',';
|
$settingString .= ',';
|
||||||
}
|
}
|
||||||
|
|
||||||
$repeat = $pSheet->getPageSetup()->getRowsToRepeatAtTop();
|
$repeat = $pSheet->getPageSetup()->getRowsToRepeatAtTop();
|
||||||
|
|
||||||
$settingString .= '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!$' . $repeat[0] . ':$' . $repeat[1];
|
$settingString .= '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!$' . $repeat[0] . ':$' . $repeat[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->writeRawData($settingString);
|
$objWriter->writeRawData($settingString);
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Defined Name for PrintTitles
|
* Write Defined Name for PrintTitles
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||||
* @param PHPExcel_Worksheet $pSheet
|
* @param PHPExcel_Worksheet $pSheet
|
||||||
* @param int $pSheetId
|
* @param int $pSheetId
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
private function _writeDefinedNameForPrintArea(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
|
private function _writeDefinedNameForPrintArea(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
|
||||||
{
|
{
|
||||||
// definedName for PrintArea
|
// definedName for PrintArea
|
||||||
if ($pSheet->getPageSetup()->isPrintAreaSet()) {
|
if ($pSheet->getPageSetup()->isPrintAreaSet()) {
|
||||||
$objWriter->startElement('definedName');
|
$objWriter->startElement('definedName');
|
||||||
$objWriter->writeAttribute('name', '_xlnm.Print_Area');
|
$objWriter->writeAttribute('name', '_xlnm.Print_Area');
|
||||||
$objWriter->writeAttribute('localSheetId', $pSheetId);
|
$objWriter->writeAttribute('localSheetId', $pSheetId);
|
||||||
|
|
||||||
// Setting string
|
// Setting string
|
||||||
$settingString = '';
|
$settingString = '';
|
||||||
|
|
||||||
// Print area
|
// Print area
|
||||||
$printArea = PHPExcel_Cell::splitRange($pSheet->getPageSetup()->getPrintArea());
|
$printArea = PHPExcel_Cell::splitRange($pSheet->getPageSetup()->getPrintArea());
|
||||||
|
|
||||||
$chunks = array();
|
$chunks = array();
|
||||||
foreach ($printArea as $printAreaRect) {
|
foreach ($printArea as $printAreaRect) {
|
||||||
$printAreaRect[0] = PHPExcel_Cell::absoluteReference($printAreaRect[0]);
|
$printAreaRect[0] = PHPExcel_Cell::absoluteReference($printAreaRect[0]);
|
||||||
$printAreaRect[1] = PHPExcel_Cell::absoluteReference($printAreaRect[1]);
|
$printAreaRect[1] = PHPExcel_Cell::absoluteReference($printAreaRect[1]);
|
||||||
$chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect);
|
$chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter->writeRawData(implode(',', $chunks));
|
$objWriter->writeRawData(implode(',', $chunks));
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -35,47 +35,47 @@
|
|||||||
*/
|
*/
|
||||||
abstract class PHPExcel_Writer_Excel2007_WriterPart
|
abstract class PHPExcel_Writer_Excel2007_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Parent IWriter object
|
* Parent IWriter object
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Writer_IWriter
|
* @var PHPExcel_Writer_IWriter
|
||||||
*/
|
*/
|
||||||
private $_parentWriter;
|
private $_parentWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set parent IWriter object
|
* Set parent IWriter object
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Writer_IWriter $pWriter
|
* @param PHPExcel_Writer_IWriter $pWriter
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function setParentWriter(PHPExcel_Writer_IWriter $pWriter = null) {
|
public function setParentWriter(PHPExcel_Writer_IWriter $pWriter = null) {
|
||||||
$this->_parentWriter = $pWriter;
|
$this->_parentWriter = $pWriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parent IWriter object
|
* Get parent IWriter object
|
||||||
*
|
*
|
||||||
* @return PHPExcel_Writer_IWriter
|
* @return PHPExcel_Writer_IWriter
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function getParentWriter() {
|
public function getParentWriter() {
|
||||||
if (!is_null($this->_parentWriter)) {
|
if (!is_null($this->_parentWriter)) {
|
||||||
return $this->_parentWriter;
|
return $this->_parentWriter;
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception("No parent PHPExcel_Writer_IWriter assigned.");
|
throw new PHPExcel_Writer_Exception("No parent PHPExcel_Writer_IWriter assigned.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set parent IWriter object
|
* Set parent IWriter object
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Writer_IWriter $pWriter
|
* @param PHPExcel_Writer_IWriter $pWriter
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function __construct(PHPExcel_Writer_IWriter $pWriter = null) {
|
public function __construct(PHPExcel_Writer_IWriter $pWriter = null) {
|
||||||
if (!is_null($pWriter)) {
|
if (!is_null($pWriter)) {
|
||||||
$this->_parentWriter = $pWriter;
|
$this->_parentWriter = $pWriter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel5
|
* @package PHPExcel_Writer_Excel5
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -69,187 +69,187 @@
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Writer_Excel5_BIFFwriter
|
class PHPExcel_Writer_Excel5_BIFFwriter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The byte order of this architecture. 0 => little endian, 1 => big endian
|
* The byte order of this architecture. 0 => little endian, 1 => big endian
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
private static $_byte_order;
|
private static $_byte_order;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The string containing the data of the BIFF stream
|
* The string containing the data of the BIFF stream
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $_data;
|
public $_data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size of the data in bytes. Should be the same as strlen($this->_data)
|
* The size of the data in bytes. Should be the same as strlen($this->_data)
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $_datasize;
|
public $_datasize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum length for a BIFF record (excluding record header and length field). See _addContinue()
|
* The maximum length for a BIFF record (excluding record header and length field). See _addContinue()
|
||||||
* @var integer
|
* @var integer
|
||||||
* @see _addContinue()
|
* @see _addContinue()
|
||||||
*/
|
*/
|
||||||
public $_limit = 8224;
|
public $_limit = 8224;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->_data = '';
|
$this->_data = '';
|
||||||
$this->_datasize = 0;
|
$this->_datasize = 0;
|
||||||
// $this->_limit = 8224;
|
// $this->_limit = 8224;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the byte order and store it as class data to avoid
|
* Determine the byte order and store it as class data to avoid
|
||||||
* recalculating it for each call to new().
|
* recalculating it for each call to new().
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function getByteOrder()
|
public static function getByteOrder()
|
||||||
{
|
{
|
||||||
if (!isset(self::$_byte_order)) {
|
if (!isset(self::$_byte_order)) {
|
||||||
// Check if "pack" gives the required IEEE 64bit float
|
// Check if "pack" gives the required IEEE 64bit float
|
||||||
$teststr = pack("d", 1.2345);
|
$teststr = pack("d", 1.2345);
|
||||||
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
|
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
|
||||||
if ($number == $teststr) {
|
if ($number == $teststr) {
|
||||||
$byte_order = 0; // Little Endian
|
$byte_order = 0; // Little Endian
|
||||||
} elseif ($number == strrev($teststr)){
|
} elseif ($number == strrev($teststr)){
|
||||||
$byte_order = 1; // Big Endian
|
$byte_order = 1; // Big Endian
|
||||||
} else {
|
} else {
|
||||||
// Give up. I'll fix this in a later version.
|
// Give up. I'll fix this in a later version.
|
||||||
throw new PHPExcel_Writer_Exception("Required floating point format not supported on this platform.");
|
throw new PHPExcel_Writer_Exception("Required floating point format not supported on this platform.");
|
||||||
}
|
}
|
||||||
self::$_byte_order = $byte_order;
|
self::$_byte_order = $byte_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$_byte_order;
|
return self::$_byte_order;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General storage function
|
* General storage function
|
||||||
*
|
*
|
||||||
* @param string $data binary data to append
|
* @param string $data binary data to append
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _append($data)
|
function _append($data)
|
||||||
{
|
{
|
||||||
if (strlen($data) - 4 > $this->_limit) {
|
if (strlen($data) - 4 > $this->_limit) {
|
||||||
$data = $this->_addContinue($data);
|
$data = $this->_addContinue($data);
|
||||||
}
|
}
|
||||||
$this->_data .= $data;
|
$this->_data .= $data;
|
||||||
$this->_datasize += strlen($data);
|
$this->_datasize += strlen($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General storage function like _append, but returns string instead of modifying $this->_data
|
* General storage function like _append, but returns string instead of modifying $this->_data
|
||||||
*
|
*
|
||||||
* @param string $data binary data to write
|
* @param string $data binary data to write
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function writeData($data)
|
public function writeData($data)
|
||||||
{
|
{
|
||||||
if (strlen($data) - 4 > $this->_limit) {
|
if (strlen($data) - 4 > $this->_limit) {
|
||||||
$data = $this->_addContinue($data);
|
$data = $this->_addContinue($data);
|
||||||
}
|
}
|
||||||
$this->_datasize += strlen($data);
|
$this->_datasize += strlen($data);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes Excel BOF record to indicate the beginning of a stream or
|
* Writes Excel BOF record to indicate the beginning of a stream or
|
||||||
* sub-stream in the BIFF file.
|
* sub-stream in the BIFF file.
|
||||||
*
|
*
|
||||||
* @param integer $type Type of BIFF file to write: 0x0005 Workbook,
|
* @param integer $type Type of BIFF file to write: 0x0005 Workbook,
|
||||||
* 0x0010 Worksheet.
|
* 0x0010 Worksheet.
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _storeBof($type)
|
function _storeBof($type)
|
||||||
{
|
{
|
||||||
$record = 0x0809; // Record identifier (BIFF5-BIFF8)
|
$record = 0x0809; // Record identifier (BIFF5-BIFF8)
|
||||||
$length = 0x0010;
|
$length = 0x0010;
|
||||||
|
|
||||||
// by inspection of real files, MS Office Excel 2007 writes the following
|
// by inspection of real files, MS Office Excel 2007 writes the following
|
||||||
$unknown = pack("VV", 0x000100D1, 0x00000406);
|
$unknown = pack("VV", 0x000100D1, 0x00000406);
|
||||||
|
|
||||||
$build = 0x0DBB; // Excel 97
|
$build = 0x0DBB; // Excel 97
|
||||||
$year = 0x07CC; // Excel 97
|
$year = 0x07CC; // Excel 97
|
||||||
|
|
||||||
$version = 0x0600; // BIFF8
|
$version = 0x0600; // BIFF8
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$data = pack("vvvv", $version, $type, $build, $year);
|
$data = pack("vvvv", $version, $type, $build, $year);
|
||||||
$this->_append($header . $data . $unknown);
|
$this->_append($header . $data . $unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes Excel EOF record to indicate the end of a BIFF stream.
|
* Writes Excel EOF record to indicate the end of a BIFF stream.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _storeEof()
|
function _storeEof()
|
||||||
{
|
{
|
||||||
$record = 0x000A; // Record identifier
|
$record = 0x000A; // Record identifier
|
||||||
$length = 0x0000; // Number of bytes to follow
|
$length = 0x0000; // Number of bytes to follow
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
$this->_append($header);
|
$this->_append($header);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes Excel EOF record to indicate the end of a BIFF stream.
|
* Writes Excel EOF record to indicate the end of a BIFF stream.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
public function writeEof()
|
public function writeEof()
|
||||||
{
|
{
|
||||||
$record = 0x000A; // Record identifier
|
$record = 0x000A; // Record identifier
|
||||||
$length = 0x0000; // Number of bytes to follow
|
$length = 0x0000; // Number of bytes to follow
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
return $this->writeData($header);
|
return $this->writeData($header);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
|
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
|
||||||
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits
|
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits
|
||||||
* must be split up into CONTINUE blocks.
|
* must be split up into CONTINUE blocks.
|
||||||
*
|
*
|
||||||
* This function takes a long BIFF record and inserts CONTINUE records as
|
* This function takes a long BIFF record and inserts CONTINUE records as
|
||||||
* necessary.
|
* necessary.
|
||||||
*
|
*
|
||||||
* @param string $data The original binary data to be written
|
* @param string $data The original binary data to be written
|
||||||
* @return string A very convenient string of continue blocks
|
* @return string A very convenient string of continue blocks
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _addContinue($data)
|
function _addContinue($data)
|
||||||
{
|
{
|
||||||
$limit = $this->_limit;
|
$limit = $this->_limit;
|
||||||
$record = 0x003C; // Record identifier
|
$record = 0x003C; // Record identifier
|
||||||
|
|
||||||
// The first 2080/8224 bytes remain intact. However, we have to change
|
// The first 2080/8224 bytes remain intact. However, we have to change
|
||||||
// the length field of the record.
|
// the length field of the record.
|
||||||
$tmp = substr($data, 0, 2) . pack("v", $limit) . substr($data, 4, $limit);
|
$tmp = substr($data, 0, 2) . pack("v", $limit) . substr($data, 4, $limit);
|
||||||
|
|
||||||
$header = pack("vv", $record, $limit); // Headers for continue records
|
$header = pack("vv", $record, $limit); // Headers for continue records
|
||||||
|
|
||||||
// Retrieve chunks of 2080/8224 bytes +4 for the header.
|
// Retrieve chunks of 2080/8224 bytes +4 for the header.
|
||||||
$data_length = strlen($data);
|
$data_length = strlen($data);
|
||||||
for ($i = $limit + 4; $i < ($data_length - $limit); $i += $limit) {
|
for ($i = $limit + 4; $i < ($data_length - $limit); $i += $limit) {
|
||||||
$tmp .= $header;
|
$tmp .= $header;
|
||||||
$tmp .= substr($data, $i, $limit);
|
$tmp .= substr($data, $i, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the last chunk of data
|
// Retrieve the last chunk of data
|
||||||
$header = pack("vv", $record, strlen($data) - $i);
|
$header = pack("vv", $record, strlen($data) - $i);
|
||||||
$tmp .= $header;
|
$tmp .= $header;
|
||||||
$tmp .= substr($data, $i, strlen($data) - $i);
|
$tmp .= substr($data, $i, strlen($data) - $i);
|
||||||
|
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel5
|
* @package PHPExcel_Writer_Excel5
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,503 +35,503 @@
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Writer_Excel5_Escher
|
class PHPExcel_Writer_Excel5_Escher
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The object we are writing
|
* The object we are writing
|
||||||
*/
|
*/
|
||||||
private $_object;
|
private $_object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The written binary data
|
* The written binary data
|
||||||
*/
|
*/
|
||||||
private $_data;
|
private $_data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shape offsets. Positions in binary stream where a new shape record begins
|
* Shape offsets. Positions in binary stream where a new shape record begins
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_spOffsets;
|
private $_spOffsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shape types.
|
* Shape types.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_spTypes;
|
private $_spTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param mixed
|
* @param mixed
|
||||||
*/
|
*/
|
||||||
public function __construct($object)
|
public function __construct($object)
|
||||||
{
|
{
|
||||||
$this->_object = $object;
|
$this->_object = $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the object to be written
|
* Process the object to be written
|
||||||
*/
|
*/
|
||||||
public function close()
|
public function close()
|
||||||
{
|
{
|
||||||
// initialize
|
// initialize
|
||||||
$this->_data = '';
|
$this->_data = '';
|
||||||
|
|
||||||
switch (get_class($this->_object)) {
|
switch (get_class($this->_object)) {
|
||||||
|
|
||||||
case 'PHPExcel_Shared_Escher':
|
case 'PHPExcel_Shared_Escher':
|
||||||
if ($dggContainer = $this->_object->getDggContainer()) {
|
if ($dggContainer = $this->_object->getDggContainer()) {
|
||||||
$writer = new PHPExcel_Writer_Excel5_Escher($dggContainer);
|
$writer = new PHPExcel_Writer_Excel5_Escher($dggContainer);
|
||||||
$this->_data = $writer->close();
|
$this->_data = $writer->close();
|
||||||
} else if ($dgContainer = $this->_object->getDgContainer()) {
|
} else if ($dgContainer = $this->_object->getDgContainer()) {
|
||||||
$writer = new PHPExcel_Writer_Excel5_Escher($dgContainer);
|
$writer = new PHPExcel_Writer_Excel5_Escher($dgContainer);
|
||||||
$this->_data = $writer->close();
|
$this->_data = $writer->close();
|
||||||
$this->_spOffsets = $writer->getSpOffsets();
|
$this->_spOffsets = $writer->getSpOffsets();
|
||||||
$this->_spTypes = $writer->getSpTypes();
|
$this->_spTypes = $writer->getSpTypes();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PHPExcel_Shared_Escher_DggContainer':
|
case 'PHPExcel_Shared_Escher_DggContainer':
|
||||||
// this is a container record
|
// this is a container record
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
$innerData = '';
|
$innerData = '';
|
||||||
|
|
||||||
// write the dgg
|
// write the dgg
|
||||||
$recVer = 0x0;
|
$recVer = 0x0;
|
||||||
$recInstance = 0x0000;
|
$recInstance = 0x0000;
|
||||||
$recType = 0xF006;
|
$recType = 0xF006;
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
// dgg data
|
// dgg data
|
||||||
$dggData =
|
$dggData =
|
||||||
pack('VVVV'
|
pack('VVVV'
|
||||||
, $this->_object->getSpIdMax() // maximum shape identifier increased by one
|
, $this->_object->getSpIdMax() // maximum shape identifier increased by one
|
||||||
, $this->_object->getCDgSaved() + 1 // number of file identifier clusters increased by one
|
, $this->_object->getCDgSaved() + 1 // number of file identifier clusters increased by one
|
||||||
, $this->_object->getCSpSaved()
|
, $this->_object->getCSpSaved()
|
||||||
, $this->_object->getCDgSaved() // count total number of drawings saved
|
, $this->_object->getCDgSaved() // count total number of drawings saved
|
||||||
);
|
);
|
||||||
|
|
||||||
// add file identifier clusters (one per drawing)
|
// add file identifier clusters (one per drawing)
|
||||||
$IDCLs = $this->_object->getIDCLs();
|
$IDCLs = $this->_object->getIDCLs();
|
||||||
|
|
||||||
foreach ($IDCLs as $dgId => $maxReducedSpId) {
|
foreach ($IDCLs as $dgId => $maxReducedSpId) {
|
||||||
$dggData .= pack('VV', $dgId, $maxReducedSpId + 1);
|
$dggData .= pack('VV', $dgId, $maxReducedSpId + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, strlen($dggData));
|
$header = pack('vvV', $recVerInstance, $recType, strlen($dggData));
|
||||||
$innerData .= $header . $dggData;
|
$innerData .= $header . $dggData;
|
||||||
|
|
||||||
// write the bstoreContainer
|
// write the bstoreContainer
|
||||||
if ($bstoreContainer = $this->_object->getBstoreContainer()) {
|
if ($bstoreContainer = $this->_object->getBstoreContainer()) {
|
||||||
$writer = new PHPExcel_Writer_Excel5_Escher($bstoreContainer);
|
$writer = new PHPExcel_Writer_Excel5_Escher($bstoreContainer);
|
||||||
$innerData .= $writer->close();
|
$innerData .= $writer->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the record
|
// write the record
|
||||||
$recVer = 0xF;
|
$recVer = 0xF;
|
||||||
$recInstance = 0x0000;
|
$recInstance = 0x0000;
|
||||||
$recType = 0xF000;
|
$recType = 0xF000;
|
||||||
$length = strlen($innerData);
|
$length = strlen($innerData);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
$this->_data = $header . $innerData;
|
$this->_data = $header . $innerData;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer':
|
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer':
|
||||||
// this is a container record
|
// this is a container record
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
$innerData = '';
|
$innerData = '';
|
||||||
|
|
||||||
// treat the inner data
|
// treat the inner data
|
||||||
if ($BSECollection = $this->_object->getBSECollection()) {
|
if ($BSECollection = $this->_object->getBSECollection()) {
|
||||||
foreach ($BSECollection as $BSE) {
|
foreach ($BSECollection as $BSE) {
|
||||||
$writer = new PHPExcel_Writer_Excel5_Escher($BSE);
|
$writer = new PHPExcel_Writer_Excel5_Escher($BSE);
|
||||||
$innerData .= $writer->close();
|
$innerData .= $writer->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the record
|
// write the record
|
||||||
$recVer = 0xF;
|
$recVer = 0xF;
|
||||||
$recInstance = count($this->_object->getBSECollection());
|
$recInstance = count($this->_object->getBSECollection());
|
||||||
$recType = 0xF001;
|
$recType = 0xF001;
|
||||||
$length = strlen($innerData);
|
$length = strlen($innerData);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
$this->_data = $header . $innerData;
|
$this->_data = $header . $innerData;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE':
|
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE':
|
||||||
// this is a semi-container record
|
// this is a semi-container record
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
$innerData = '';
|
$innerData = '';
|
||||||
|
|
||||||
// here we treat the inner data
|
// here we treat the inner data
|
||||||
if ($blip = $this->_object->getBlip()) {
|
if ($blip = $this->_object->getBlip()) {
|
||||||
$writer = new PHPExcel_Writer_Excel5_Escher($blip);
|
$writer = new PHPExcel_Writer_Excel5_Escher($blip);
|
||||||
$innerData .= $writer->close();
|
$innerData .= $writer->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
$data = '';
|
$data = '';
|
||||||
|
|
||||||
$btWin32 = $this->_object->getBlipType();
|
$btWin32 = $this->_object->getBlipType();
|
||||||
$btMacOS = $this->_object->getBlipType();
|
$btMacOS = $this->_object->getBlipType();
|
||||||
$data .= pack('CC', $btWin32, $btMacOS);
|
$data .= pack('CC', $btWin32, $btMacOS);
|
||||||
|
|
||||||
$rgbUid = pack('VVVV', 0,0,0,0); // todo
|
$rgbUid = pack('VVVV', 0,0,0,0); // todo
|
||||||
$data .= $rgbUid;
|
$data .= $rgbUid;
|
||||||
|
|
||||||
$tag = 0;
|
$tag = 0;
|
||||||
$size = strlen($innerData);
|
$size = strlen($innerData);
|
||||||
$cRef = 1;
|
$cRef = 1;
|
||||||
$foDelay = 0; //todo
|
$foDelay = 0; //todo
|
||||||
$unused1 = 0x0;
|
$unused1 = 0x0;
|
||||||
$cbName = 0x0;
|
$cbName = 0x0;
|
||||||
$unused2 = 0x0;
|
$unused2 = 0x0;
|
||||||
$unused3 = 0x0;
|
$unused3 = 0x0;
|
||||||
$data .= pack('vVVVCCCC', $tag, $size, $cRef, $foDelay, $unused1, $cbName, $unused2, $unused3);
|
$data .= pack('vVVVCCCC', $tag, $size, $cRef, $foDelay, $unused1, $cbName, $unused2, $unused3);
|
||||||
|
|
||||||
$data .= $innerData;
|
$data .= $innerData;
|
||||||
|
|
||||||
// write the record
|
// write the record
|
||||||
$recVer = 0x2;
|
$recVer = 0x2;
|
||||||
$recInstance = $this->_object->getBlipType();
|
$recInstance = $this->_object->getBlipType();
|
||||||
$recType = 0xF007;
|
$recType = 0xF007;
|
||||||
$length = strlen($data);
|
$length = strlen($data);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
$this->_data = $header;
|
$this->_data = $header;
|
||||||
|
|
||||||
$this->_data .= $data;
|
$this->_data .= $data;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip':
|
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip':
|
||||||
// this is an atom record
|
// this is an atom record
|
||||||
|
|
||||||
// write the record
|
// write the record
|
||||||
switch ($this->_object->getParent()->getBlipType()) {
|
switch ($this->_object->getParent()->getBlipType()) {
|
||||||
|
|
||||||
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
|
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
|
||||||
// initialize
|
// initialize
|
||||||
$innerData = '';
|
$innerData = '';
|
||||||
|
|
||||||
$rgbUid1 = pack('VVVV', 0,0,0,0); // todo
|
$rgbUid1 = pack('VVVV', 0,0,0,0); // todo
|
||||||
$innerData .= $rgbUid1;
|
$innerData .= $rgbUid1;
|
||||||
|
|
||||||
$tag = 0xFF; // todo
|
$tag = 0xFF; // todo
|
||||||
$innerData .= pack('C', $tag);
|
$innerData .= pack('C', $tag);
|
||||||
|
|
||||||
$innerData .= $this->_object->getData();
|
$innerData .= $this->_object->getData();
|
||||||
|
|
||||||
$recVer = 0x0;
|
$recVer = 0x0;
|
||||||
$recInstance = 0x46A;
|
$recInstance = 0x46A;
|
||||||
$recType = 0xF01D;
|
$recType = 0xF01D;
|
||||||
$length = strlen($innerData);
|
$length = strlen($innerData);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
$this->_data = $header;
|
$this->_data = $header;
|
||||||
|
|
||||||
$this->_data .= $innerData;
|
$this->_data .= $innerData;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG:
|
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG:
|
||||||
// initialize
|
// initialize
|
||||||
$innerData = '';
|
$innerData = '';
|
||||||
|
|
||||||
$rgbUid1 = pack('VVVV', 0,0,0,0); // todo
|
$rgbUid1 = pack('VVVV', 0,0,0,0); // todo
|
||||||
$innerData .= $rgbUid1;
|
$innerData .= $rgbUid1;
|
||||||
|
|
||||||
$tag = 0xFF; // todo
|
$tag = 0xFF; // todo
|
||||||
$innerData .= pack('C', $tag);
|
$innerData .= pack('C', $tag);
|
||||||
|
|
||||||
$innerData .= $this->_object->getData();
|
$innerData .= $this->_object->getData();
|
||||||
|
|
||||||
$recVer = 0x0;
|
$recVer = 0x0;
|
||||||
$recInstance = 0x6E0;
|
$recInstance = 0x6E0;
|
||||||
$recType = 0xF01E;
|
$recType = 0xF01E;
|
||||||
$length = strlen($innerData);
|
$length = strlen($innerData);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
$this->_data = $header;
|
$this->_data = $header;
|
||||||
|
|
||||||
$this->_data .= $innerData;
|
$this->_data .= $innerData;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PHPExcel_Shared_Escher_DgContainer':
|
case 'PHPExcel_Shared_Escher_DgContainer':
|
||||||
// this is a container record
|
// this is a container record
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
$innerData = '';
|
$innerData = '';
|
||||||
|
|
||||||
// write the dg
|
// write the dg
|
||||||
$recVer = 0x0;
|
$recVer = 0x0;
|
||||||
$recInstance = $this->_object->getDgId();
|
$recInstance = $this->_object->getDgId();
|
||||||
$recType = 0xF008;
|
$recType = 0xF008;
|
||||||
$length = 8;
|
$length = 8;
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
// number of shapes in this drawing (including group shape)
|
// number of shapes in this drawing (including group shape)
|
||||||
$countShapes = count($this->_object->getSpgrContainer()->getChildren());
|
$countShapes = count($this->_object->getSpgrContainer()->getChildren());
|
||||||
$innerData .= $header . pack('VV', $countShapes, $this->_object->getLastSpId());
|
$innerData .= $header . pack('VV', $countShapes, $this->_object->getLastSpId());
|
||||||
//$innerData .= $header . pack('VV', 0, 0);
|
//$innerData .= $header . pack('VV', 0, 0);
|
||||||
|
|
||||||
// write the spgrContainer
|
// write the spgrContainer
|
||||||
if ($spgrContainer = $this->_object->getSpgrContainer()) {
|
if ($spgrContainer = $this->_object->getSpgrContainer()) {
|
||||||
$writer = new PHPExcel_Writer_Excel5_Escher($spgrContainer);
|
$writer = new PHPExcel_Writer_Excel5_Escher($spgrContainer);
|
||||||
$innerData .= $writer->close();
|
$innerData .= $writer->close();
|
||||||
|
|
||||||
// get the shape offsets relative to the spgrContainer record
|
// get the shape offsets relative to the spgrContainer record
|
||||||
$spOffsets = $writer->getSpOffsets();
|
$spOffsets = $writer->getSpOffsets();
|
||||||
$spTypes = $writer->getSpTypes();
|
$spTypes = $writer->getSpTypes();
|
||||||
|
|
||||||
// save the shape offsets relative to dgContainer
|
// save the shape offsets relative to dgContainer
|
||||||
foreach ($spOffsets as & $spOffset) {
|
foreach ($spOffsets as & $spOffset) {
|
||||||
$spOffset += 24; // add length of dgContainer header data (8 bytes) plus dg data (16 bytes)
|
$spOffset += 24; // add length of dgContainer header data (8 bytes) plus dg data (16 bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_spOffsets = $spOffsets;
|
$this->_spOffsets = $spOffsets;
|
||||||
$this->_spTypes = $spTypes;
|
$this->_spTypes = $spTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the record
|
// write the record
|
||||||
$recVer = 0xF;
|
$recVer = 0xF;
|
||||||
$recInstance = 0x0000;
|
$recInstance = 0x0000;
|
||||||
$recType = 0xF002;
|
$recType = 0xF002;
|
||||||
$length = strlen($innerData);
|
$length = strlen($innerData);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
$this->_data = $header . $innerData;
|
$this->_data = $header . $innerData;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer':
|
case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer':
|
||||||
// this is a container record
|
// this is a container record
|
||||||
|
|
||||||
// initialize
|
// initialize
|
||||||
$innerData = '';
|
$innerData = '';
|
||||||
|
|
||||||
// initialize spape offsets
|
// initialize spape offsets
|
||||||
$totalSize = 8;
|
$totalSize = 8;
|
||||||
$spOffsets = array();
|
$spOffsets = array();
|
||||||
$spTypes = array();
|
$spTypes = array();
|
||||||
|
|
||||||
// treat the inner data
|
// treat the inner data
|
||||||
foreach ($this->_object->getChildren() as $spContainer) {
|
foreach ($this->_object->getChildren() as $spContainer) {
|
||||||
$writer = new PHPExcel_Writer_Excel5_Escher($spContainer);
|
$writer = new PHPExcel_Writer_Excel5_Escher($spContainer);
|
||||||
$spData = $writer->close();
|
$spData = $writer->close();
|
||||||
$innerData .= $spData;
|
$innerData .= $spData;
|
||||||
|
|
||||||
// save the shape offsets (where new shape records begin)
|
// save the shape offsets (where new shape records begin)
|
||||||
$totalSize += strlen($spData);
|
$totalSize += strlen($spData);
|
||||||
$spOffsets[] = $totalSize;
|
$spOffsets[] = $totalSize;
|
||||||
|
|
||||||
$spTypes = array_merge($spTypes, $writer->getSpTypes());
|
$spTypes = array_merge($spTypes, $writer->getSpTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the record
|
// write the record
|
||||||
$recVer = 0xF;
|
$recVer = 0xF;
|
||||||
$recInstance = 0x0000;
|
$recInstance = 0x0000;
|
||||||
$recType = 0xF003;
|
$recType = 0xF003;
|
||||||
$length = strlen($innerData);
|
$length = strlen($innerData);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
$this->_data = $header . $innerData;
|
$this->_data = $header . $innerData;
|
||||||
$this->_spOffsets = $spOffsets;
|
$this->_spOffsets = $spOffsets;
|
||||||
$this->_spTypes = $spTypes;
|
$this->_spTypes = $spTypes;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer':
|
case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer':
|
||||||
// initialize
|
// initialize
|
||||||
$data = '';
|
$data = '';
|
||||||
|
|
||||||
// build the data
|
// build the data
|
||||||
|
|
||||||
// write group shape record, if necessary?
|
// write group shape record, if necessary?
|
||||||
if ($this->_object->getSpgr()) {
|
if ($this->_object->getSpgr()) {
|
||||||
$recVer = 0x1;
|
$recVer = 0x1;
|
||||||
$recInstance = 0x0000;
|
$recInstance = 0x0000;
|
||||||
$recType = 0xF009;
|
$recType = 0xF009;
|
||||||
$length = 0x00000010;
|
$length = 0x00000010;
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
$data .= $header . pack('VVVV', 0,0,0,0);
|
$data .= $header . pack('VVVV', 0,0,0,0);
|
||||||
}
|
}
|
||||||
$this->_spTypes[] = ($this->_object->getSpType());
|
$this->_spTypes[] = ($this->_object->getSpType());
|
||||||
|
|
||||||
// write the shape record
|
// write the shape record
|
||||||
$recVer = 0x2;
|
$recVer = 0x2;
|
||||||
$recInstance = $this->_object->getSpType(); // shape type
|
$recInstance = $this->_object->getSpType(); // shape type
|
||||||
$recType = 0xF00A;
|
$recType = 0xF00A;
|
||||||
$length = 0x00000008;
|
$length = 0x00000008;
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
$data .= $header . pack('VV', $this->_object->getSpId(), $this->_object->getSpgr() ? 0x0005 : 0x0A00);
|
$data .= $header . pack('VV', $this->_object->getSpId(), $this->_object->getSpgr() ? 0x0005 : 0x0A00);
|
||||||
|
|
||||||
|
|
||||||
// the options
|
// the options
|
||||||
if ($this->_object->getOPTCollection()) {
|
if ($this->_object->getOPTCollection()) {
|
||||||
$optData = '';
|
$optData = '';
|
||||||
|
|
||||||
$recVer = 0x3;
|
$recVer = 0x3;
|
||||||
$recInstance = count($this->_object->getOPTCollection());
|
$recInstance = count($this->_object->getOPTCollection());
|
||||||
$recType = 0xF00B;
|
$recType = 0xF00B;
|
||||||
foreach ($this->_object->getOPTCollection() as $property => $value) {
|
foreach ($this->_object->getOPTCollection() as $property => $value) {
|
||||||
$optData .= pack('vV', $property, $value);
|
$optData .= pack('vV', $property, $value);
|
||||||
}
|
}
|
||||||
$length = strlen($optData);
|
$length = strlen($optData);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
$data .= $header . $optData;
|
$data .= $header . $optData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the client anchor
|
// the client anchor
|
||||||
if ($this->_object->getStartCoordinates()) {
|
if ($this->_object->getStartCoordinates()) {
|
||||||
$clientAnchorData = '';
|
$clientAnchorData = '';
|
||||||
|
|
||||||
$recVer = 0x0;
|
$recVer = 0x0;
|
||||||
$recInstance = 0x0;
|
$recInstance = 0x0;
|
||||||
$recType = 0xF010;
|
$recType = 0xF010;
|
||||||
|
|
||||||
// start coordinates
|
// start coordinates
|
||||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($this->_object->getStartCoordinates());
|
list($column, $row) = PHPExcel_Cell::coordinateFromString($this->_object->getStartCoordinates());
|
||||||
$c1 = PHPExcel_Cell::columnIndexFromString($column) - 1;
|
$c1 = PHPExcel_Cell::columnIndexFromString($column) - 1;
|
||||||
$r1 = $row - 1;
|
$r1 = $row - 1;
|
||||||
|
|
||||||
// start offsetX
|
// start offsetX
|
||||||
$startOffsetX = $this->_object->getStartOffsetX();
|
$startOffsetX = $this->_object->getStartOffsetX();
|
||||||
|
|
||||||
// start offsetY
|
// start offsetY
|
||||||
$startOffsetY = $this->_object->getStartOffsetY();
|
$startOffsetY = $this->_object->getStartOffsetY();
|
||||||
|
|
||||||
// end coordinates
|
// end coordinates
|
||||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($this->_object->getEndCoordinates());
|
list($column, $row) = PHPExcel_Cell::coordinateFromString($this->_object->getEndCoordinates());
|
||||||
$c2 = PHPExcel_Cell::columnIndexFromString($column) - 1;
|
$c2 = PHPExcel_Cell::columnIndexFromString($column) - 1;
|
||||||
$r2 = $row - 1;
|
$r2 = $row - 1;
|
||||||
|
|
||||||
// end offsetX
|
// end offsetX
|
||||||
$endOffsetX = $this->_object->getEndOffsetX();
|
$endOffsetX = $this->_object->getEndOffsetX();
|
||||||
|
|
||||||
// end offsetY
|
// end offsetY
|
||||||
$endOffsetY = $this->_object->getEndOffsetY();
|
$endOffsetY = $this->_object->getEndOffsetY();
|
||||||
|
|
||||||
$clientAnchorData = pack('vvvvvvvvv', $this->_object->getSpFlag(),
|
$clientAnchorData = pack('vvvvvvvvv', $this->_object->getSpFlag(),
|
||||||
$c1, $startOffsetX, $r1, $startOffsetY,
|
$c1, $startOffsetX, $r1, $startOffsetY,
|
||||||
$c2, $endOffsetX, $r2, $endOffsetY);
|
$c2, $endOffsetX, $r2, $endOffsetY);
|
||||||
|
|
||||||
$length = strlen($clientAnchorData);
|
$length = strlen($clientAnchorData);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
$data .= $header . $clientAnchorData;
|
$data .= $header . $clientAnchorData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the client data, just empty for now
|
// the client data, just empty for now
|
||||||
if (!$this->_object->getSpgr()) {
|
if (!$this->_object->getSpgr()) {
|
||||||
$clientDataData = '';
|
$clientDataData = '';
|
||||||
|
|
||||||
$recVer = 0x0;
|
$recVer = 0x0;
|
||||||
$recInstance = 0x0;
|
$recInstance = 0x0;
|
||||||
$recType = 0xF011;
|
$recType = 0xF011;
|
||||||
|
|
||||||
$length = strlen($clientDataData);
|
$length = strlen($clientDataData);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
$data .= $header . $clientDataData;
|
$data .= $header . $clientDataData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write the record
|
// write the record
|
||||||
$recVer = 0xF;
|
$recVer = 0xF;
|
||||||
$recInstance = 0x0000;
|
$recInstance = 0x0000;
|
||||||
$recType = 0xF004;
|
$recType = 0xF004;
|
||||||
$length = strlen($data);
|
$length = strlen($data);
|
||||||
|
|
||||||
$recVerInstance = $recVer;
|
$recVerInstance = $recVer;
|
||||||
$recVerInstance |= $recInstance << 4;
|
$recVerInstance |= $recInstance << 4;
|
||||||
|
|
||||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||||
|
|
||||||
$this->_data = $header . $data;
|
$this->_data = $header . $data;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_data;
|
return $this->_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the shape offsets
|
* Gets the shape offsets
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getSpOffsets()
|
public function getSpOffsets()
|
||||||
{
|
{
|
||||||
return $this->_spOffsets;
|
return $this->_spOffsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the shape types
|
* Gets the shape types
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getSpTypes()
|
public function getSpTypes()
|
||||||
{
|
{
|
||||||
return $this->_spTypes;
|
return $this->_spTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel5
|
* @package PHPExcel_Writer_Excel5
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,131 +35,131 @@
|
|||||||
*/
|
*/
|
||||||
class PHPExcel_Writer_Excel5_Font
|
class PHPExcel_Writer_Excel5_Font
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Color index
|
* Color index
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_colorIndex;
|
private $_colorIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Font
|
* Font
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Style_Font
|
* @var PHPExcel_Style_Font
|
||||||
*/
|
*/
|
||||||
private $_font;
|
private $_font;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param PHPExcel_Style_Font $font
|
* @param PHPExcel_Style_Font $font
|
||||||
*/
|
*/
|
||||||
public function __construct(PHPExcel_Style_Font $font = null)
|
public function __construct(PHPExcel_Style_Font $font = null)
|
||||||
{
|
{
|
||||||
$this->_colorIndex = 0x7FFF;
|
$this->_colorIndex = 0x7FFF;
|
||||||
$this->_font = $font;
|
$this->_font = $font;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the color index
|
* Set the color index
|
||||||
*
|
*
|
||||||
* @param int $colorIndex
|
* @param int $colorIndex
|
||||||
*/
|
*/
|
||||||
public function setColorIndex($colorIndex)
|
public function setColorIndex($colorIndex)
|
||||||
{
|
{
|
||||||
$this->_colorIndex = $colorIndex;
|
$this->_colorIndex = $colorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get font record data
|
* Get font record data
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function writeFont()
|
public function writeFont()
|
||||||
{
|
{
|
||||||
$font_outline = 0;
|
$font_outline = 0;
|
||||||
$font_shadow = 0;
|
$font_shadow = 0;
|
||||||
|
|
||||||
$icv = $this->_colorIndex; // Index to color palette
|
$icv = $this->_colorIndex; // Index to color palette
|
||||||
if ($this->_font->getSuperScript()) {
|
if ($this->_font->getSuperScript()) {
|
||||||
$sss = 1;
|
$sss = 1;
|
||||||
} else if ($this->_font->getSubScript()) {
|
} else if ($this->_font->getSubScript()) {
|
||||||
$sss = 2;
|
$sss = 2;
|
||||||
} else {
|
} else {
|
||||||
$sss = 0;
|
$sss = 0;
|
||||||
}
|
}
|
||||||
$bFamily = 0; // Font family
|
$bFamily = 0; // Font family
|
||||||
$bCharSet = PHPExcel_Shared_Font::getCharsetFromFontName($this->_font->getName()); // Character set
|
$bCharSet = PHPExcel_Shared_Font::getCharsetFromFontName($this->_font->getName()); // Character set
|
||||||
|
|
||||||
$record = 0x31; // Record identifier
|
$record = 0x31; // Record identifier
|
||||||
$reserved = 0x00; // Reserved
|
$reserved = 0x00; // Reserved
|
||||||
$grbit = 0x00; // Font attributes
|
$grbit = 0x00; // Font attributes
|
||||||
if ($this->_font->getItalic()) {
|
if ($this->_font->getItalic()) {
|
||||||
$grbit |= 0x02;
|
$grbit |= 0x02;
|
||||||
}
|
}
|
||||||
if ($this->_font->getStrikethrough()) {
|
if ($this->_font->getStrikethrough()) {
|
||||||
$grbit |= 0x08;
|
$grbit |= 0x08;
|
||||||
}
|
}
|
||||||
if ($font_outline) {
|
if ($font_outline) {
|
||||||
$grbit |= 0x10;
|
$grbit |= 0x10;
|
||||||
}
|
}
|
||||||
if ($font_shadow) {
|
if ($font_shadow) {
|
||||||
$grbit |= 0x20;
|
$grbit |= 0x20;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = pack("vvvvvCCCC",
|
$data = pack("vvvvvCCCC",
|
||||||
$this->_font->getSize() * 20, // Fontsize (in twips)
|
$this->_font->getSize() * 20, // Fontsize (in twips)
|
||||||
$grbit,
|
$grbit,
|
||||||
$icv, // Colour
|
$icv, // Colour
|
||||||
self::_mapBold($this->_font->getBold()), // Font weight
|
self::_mapBold($this->_font->getBold()), // Font weight
|
||||||
$sss, // Superscript/Subscript
|
$sss, // Superscript/Subscript
|
||||||
self::_mapUnderline($this->_font->getUnderline()),
|
self::_mapUnderline($this->_font->getUnderline()),
|
||||||
$bFamily,
|
$bFamily,
|
||||||
$bCharSet,
|
$bCharSet,
|
||||||
$reserved
|
$reserved
|
||||||
);
|
);
|
||||||
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->_font->getName());
|
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->_font->getName());
|
||||||
|
|
||||||
$length = strlen($data);
|
$length = strlen($data);
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
|
|
||||||
return($header . $data);
|
return($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map to BIFF5-BIFF8 codes for bold
|
* Map to BIFF5-BIFF8 codes for bold
|
||||||
*
|
*
|
||||||
* @param boolean $bold
|
* @param boolean $bold
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private static function _mapBold($bold) {
|
private static function _mapBold($bold) {
|
||||||
if ($bold) {
|
if ($bold) {
|
||||||
return 0x2BC; // 700 = Bold font weight
|
return 0x2BC; // 700 = Bold font weight
|
||||||
}
|
}
|
||||||
return 0x190; // 400 = Normal font weight
|
return 0x190; // 400 = Normal font weight
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of BIFF2-BIFF8 codes for underline styles
|
* Map of BIFF2-BIFF8 codes for underline styles
|
||||||
* @static array of int
|
* @static array of int
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static $_mapUnderline = array( PHPExcel_Style_Font::UNDERLINE_NONE => 0x00,
|
private static $_mapUnderline = array( PHPExcel_Style_Font::UNDERLINE_NONE => 0x00,
|
||||||
PHPExcel_Style_Font::UNDERLINE_SINGLE => 0x01,
|
PHPExcel_Style_Font::UNDERLINE_SINGLE => 0x01,
|
||||||
PHPExcel_Style_Font::UNDERLINE_DOUBLE => 0x02,
|
PHPExcel_Style_Font::UNDERLINE_DOUBLE => 0x02,
|
||||||
PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING => 0x21,
|
PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING => 0x21,
|
||||||
PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING => 0x22,
|
PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING => 0x22,
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* Map underline
|
* Map underline
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private static function _mapUnderline($underline) {
|
private static function _mapUnderline($underline) {
|
||||||
if (isset(self::$_mapUnderline[$underline]))
|
if (isset(self::$_mapUnderline[$underline]))
|
||||||
return self::$_mapUnderline[$underline];
|
return self::$_mapUnderline[$underline];
|
||||||
return 0x00;
|
return 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_Excel5
|
* @package PHPExcel_Writer_Excel5
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -71,477 +71,477 @@
|
|||||||
class PHPExcel_Writer_Excel5_Xf
|
class PHPExcel_Writer_Excel5_Xf
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Style XF or a cell XF ?
|
* Style XF or a cell XF ?
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_isStyleXf;
|
private $_isStyleXf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index to the FONT record. Index 4 does not exist
|
* Index to the FONT record. Index 4 does not exist
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
private $_fontIndex;
|
private $_fontIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An index (2 bytes) to a FORMAT record (number format).
|
* An index (2 bytes) to a FORMAT record (number format).
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $_numberFormatIndex;
|
public $_numberFormatIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1 bit, apparently not used.
|
* 1 bit, apparently not used.
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $_text_justlast;
|
public $_text_justlast;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cell's foreground color.
|
* The cell's foreground color.
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $_fg_color;
|
public $_fg_color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cell's background color.
|
* The cell's background color.
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $_bg_color;
|
public $_bg_color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color of the bottom border of the cell.
|
* Color of the bottom border of the cell.
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $_bottom_color;
|
public $_bottom_color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color of the top border of the cell.
|
* Color of the top border of the cell.
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $_top_color;
|
public $_top_color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color of the left border of the cell.
|
* Color of the left border of the cell.
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $_left_color;
|
public $_left_color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color of the right border of the cell.
|
* Color of the right border of the cell.
|
||||||
* @var integer
|
* @var integer
|
||||||
*/
|
*/
|
||||||
public $_right_color;
|
public $_right_color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param PHPExcel_Style The XF format
|
* @param PHPExcel_Style The XF format
|
||||||
*/
|
*/
|
||||||
public function __construct(PHPExcel_Style $style = null)
|
public function __construct(PHPExcel_Style $style = null)
|
||||||
{
|
{
|
||||||
$this->_isStyleXf = false;
|
$this->_isStyleXf = false;
|
||||||
$this->_fontIndex = 0;
|
$this->_fontIndex = 0;
|
||||||
|
|
||||||
$this->_numberFormatIndex = 0;
|
$this->_numberFormatIndex = 0;
|
||||||
|
|
||||||
$this->_text_justlast = 0;
|
$this->_text_justlast = 0;
|
||||||
|
|
||||||
$this->_fg_color = 0x40;
|
$this->_fg_color = 0x40;
|
||||||
$this->_bg_color = 0x41;
|
$this->_bg_color = 0x41;
|
||||||
|
|
||||||
$this->_diag = 0;
|
$this->_diag = 0;
|
||||||
|
|
||||||
$this->_bottom_color = 0x40;
|
$this->_bottom_color = 0x40;
|
||||||
$this->_top_color = 0x40;
|
$this->_top_color = 0x40;
|
||||||
$this->_left_color = 0x40;
|
$this->_left_color = 0x40;
|
||||||
$this->_right_color = 0x40;
|
$this->_right_color = 0x40;
|
||||||
$this->_diag_color = 0x40;
|
$this->_diag_color = 0x40;
|
||||||
$this->_style = $style;
|
$this->_style = $style;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an Excel BIFF XF record (style or cell).
|
* Generate an Excel BIFF XF record (style or cell).
|
||||||
*
|
*
|
||||||
* @return string The XF record
|
* @return string The XF record
|
||||||
*/
|
*/
|
||||||
function writeXf()
|
function writeXf()
|
||||||
{
|
{
|
||||||
// Set the type of the XF record and some of the attributes.
|
// Set the type of the XF record and some of the attributes.
|
||||||
if ($this->_isStyleXf) {
|
if ($this->_isStyleXf) {
|
||||||
$style = 0xFFF5;
|
$style = 0xFFF5;
|
||||||
} else {
|
} else {
|
||||||
$style = self::_mapLocked($this->_style->getProtection()->getLocked());
|
$style = self::_mapLocked($this->_style->getProtection()->getLocked());
|
||||||
$style |= self::_mapHidden($this->_style->getProtection()->getHidden()) << 1;
|
$style |= self::_mapHidden($this->_style->getProtection()->getHidden()) << 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flags to indicate if attributes have been set.
|
// Flags to indicate if attributes have been set.
|
||||||
$atr_num = ($this->_numberFormatIndex != 0)?1:0;
|
$atr_num = ($this->_numberFormatIndex != 0)?1:0;
|
||||||
$atr_fnt = ($this->_fontIndex != 0)?1:0;
|
$atr_fnt = ($this->_fontIndex != 0)?1:0;
|
||||||
$atr_alc = ((int) $this->_style->getAlignment()->getWrapText()) ? 1 : 0;
|
$atr_alc = ((int) $this->_style->getAlignment()->getWrapText()) ? 1 : 0;
|
||||||
$atr_bdr = (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) ||
|
$atr_bdr = (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) ||
|
||||||
self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) ||
|
self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) ||
|
||||||
self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) ||
|
self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) ||
|
||||||
self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0;
|
self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0;
|
||||||
$atr_pat = (($this->_fg_color != 0x40) ||
|
$atr_pat = (($this->_fg_color != 0x40) ||
|
||||||
($this->_bg_color != 0x41) ||
|
($this->_bg_color != 0x41) ||
|
||||||
self::_mapFillType($this->_style->getFill()->getFillType()))?1:0;
|
self::_mapFillType($this->_style->getFill()->getFillType()))?1:0;
|
||||||
$atr_prot = self::_mapLocked($this->_style->getProtection()->getLocked())
|
$atr_prot = self::_mapLocked($this->_style->getProtection()->getLocked())
|
||||||
| self::_mapHidden($this->_style->getProtection()->getHidden());
|
| self::_mapHidden($this->_style->getProtection()->getHidden());
|
||||||
|
|
||||||
// Zero the default border colour if the border has not been set.
|
// Zero the default border colour if the border has not been set.
|
||||||
if (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
|
if (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
|
||||||
$this->_bottom_color = 0;
|
$this->_bottom_color = 0;
|
||||||
}
|
}
|
||||||
if (self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) {
|
if (self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) {
|
||||||
$this->_top_color = 0;
|
$this->_top_color = 0;
|
||||||
}
|
}
|
||||||
if (self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
|
if (self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
|
||||||
$this->_right_color = 0;
|
$this->_right_color = 0;
|
||||||
}
|
}
|
||||||
if (self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
|
if (self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
|
||||||
$this->_left_color = 0;
|
$this->_left_color = 0;
|
||||||
}
|
}
|
||||||
if (self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
|
if (self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
|
||||||
$this->_diag_color = 0;
|
$this->_diag_color = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$record = 0x00E0; // Record identifier
|
$record = 0x00E0; // Record identifier
|
||||||
$length = 0x0014; // Number of bytes to follow
|
$length = 0x0014; // Number of bytes to follow
|
||||||
|
|
||||||
$ifnt = $this->_fontIndex; // Index to FONT record
|
$ifnt = $this->_fontIndex; // Index to FONT record
|
||||||
$ifmt = $this->_numberFormatIndex; // Index to FORMAT record
|
$ifmt = $this->_numberFormatIndex; // Index to FORMAT record
|
||||||
|
|
||||||
$align = $this->_mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment
|
$align = $this->_mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment
|
||||||
$align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
|
$align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
|
||||||
$align |= self::_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
|
$align |= self::_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
|
||||||
$align |= $this->_text_justlast << 7;
|
$align |= $this->_text_justlast << 7;
|
||||||
|
|
||||||
$used_attrib = $atr_num << 2;
|
$used_attrib = $atr_num << 2;
|
||||||
$used_attrib |= $atr_fnt << 3;
|
$used_attrib |= $atr_fnt << 3;
|
||||||
$used_attrib |= $atr_alc << 4;
|
$used_attrib |= $atr_alc << 4;
|
||||||
$used_attrib |= $atr_bdr << 5;
|
$used_attrib |= $atr_bdr << 5;
|
||||||
$used_attrib |= $atr_pat << 6;
|
$used_attrib |= $atr_pat << 6;
|
||||||
$used_attrib |= $atr_prot << 7;
|
$used_attrib |= $atr_prot << 7;
|
||||||
|
|
||||||
$icv = $this->_fg_color; // fg and bg pattern colors
|
$icv = $this->_fg_color; // fg and bg pattern colors
|
||||||
$icv |= $this->_bg_color << 7;
|
$icv |= $this->_bg_color << 7;
|
||||||
|
|
||||||
$border1 = self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color
|
$border1 = self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color
|
||||||
$border1 |= self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
|
$border1 |= self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
|
||||||
$border1 |= self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
|
$border1 |= self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
|
||||||
$border1 |= self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
|
$border1 |= self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
|
||||||
$border1 |= $this->_left_color << 16;
|
$border1 |= $this->_left_color << 16;
|
||||||
$border1 |= $this->_right_color << 23;
|
$border1 |= $this->_right_color << 23;
|
||||||
|
|
||||||
$diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
|
$diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
|
||||||
$diag_tl_to_rb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|
$diag_tl_to_rb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|
||||||
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN;
|
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN;
|
||||||
$diag_tr_to_lb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|
$diag_tr_to_lb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|
||||||
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP;
|
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP;
|
||||||
$border1 |= $diag_tl_to_rb << 30;
|
$border1 |= $diag_tl_to_rb << 30;
|
||||||
$border1 |= $diag_tr_to_lb << 31;
|
$border1 |= $diag_tr_to_lb << 31;
|
||||||
|
|
||||||
$border2 = $this->_top_color; // Border color
|
$border2 = $this->_top_color; // Border color
|
||||||
$border2 |= $this->_bottom_color << 7;
|
$border2 |= $this->_bottom_color << 7;
|
||||||
$border2 |= $this->_diag_color << 14;
|
$border2 |= $this->_diag_color << 14;
|
||||||
$border2 |= self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
|
$border2 |= self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
|
||||||
$border2 |= self::_mapFillType($this->_style->getFill()->getFillType()) << 26;
|
$border2 |= self::_mapFillType($this->_style->getFill()->getFillType()) << 26;
|
||||||
|
|
||||||
$header = pack("vv", $record, $length);
|
$header = pack("vv", $record, $length);
|
||||||
|
|
||||||
//BIFF8 options: identation, shrinkToFit and text direction
|
//BIFF8 options: identation, shrinkToFit and text direction
|
||||||
$biff8_options = $this->_style->getAlignment()->getIndent();
|
$biff8_options = $this->_style->getAlignment()->getIndent();
|
||||||
$biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
|
$biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
|
||||||
|
|
||||||
$data = pack("vvvC", $ifnt, $ifmt, $style, $align);
|
$data = pack("vvvC", $ifnt, $ifmt, $style, $align);
|
||||||
$data .= pack("CCC"
|
$data .= pack("CCC"
|
||||||
, self::_mapTextRotation($this->_style->getAlignment()->getTextRotation())
|
, self::_mapTextRotation($this->_style->getAlignment()->getTextRotation())
|
||||||
, $biff8_options
|
, $biff8_options
|
||||||
, $used_attrib
|
, $used_attrib
|
||||||
);
|
);
|
||||||
$data .= pack("VVv", $border1, $border2, $icv);
|
$data .= pack("VVv", $border1, $border2, $icv);
|
||||||
|
|
||||||
return($header . $data);
|
return($header . $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this a style XF ?
|
* Is this a style XF ?
|
||||||
*
|
*
|
||||||
* @param boolean $value
|
* @param boolean $value
|
||||||
*/
|
*/
|
||||||
public function setIsStyleXf($value)
|
public function setIsStyleXf($value)
|
||||||
{
|
{
|
||||||
$this->_isStyleXf = $value;
|
$this->_isStyleXf = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the cell's bottom border color
|
* Sets the cell's bottom border color
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param int $colorIndex Color index
|
* @param int $colorIndex Color index
|
||||||
*/
|
*/
|
||||||
function setBottomColor($colorIndex)
|
function setBottomColor($colorIndex)
|
||||||
{
|
{
|
||||||
$this->_bottom_color = $colorIndex;
|
$this->_bottom_color = $colorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the cell's top border color
|
* Sets the cell's top border color
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param int $colorIndex Color index
|
* @param int $colorIndex Color index
|
||||||
*/
|
*/
|
||||||
function setTopColor($colorIndex)
|
function setTopColor($colorIndex)
|
||||||
{
|
{
|
||||||
$this->_top_color = $colorIndex;
|
$this->_top_color = $colorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the cell's left border color
|
* Sets the cell's left border color
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param int $colorIndex Color index
|
* @param int $colorIndex Color index
|
||||||
*/
|
*/
|
||||||
function setLeftColor($colorIndex)
|
function setLeftColor($colorIndex)
|
||||||
{
|
{
|
||||||
$this->_left_color = $colorIndex;
|
$this->_left_color = $colorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the cell's right border color
|
* Sets the cell's right border color
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param int $colorIndex Color index
|
* @param int $colorIndex Color index
|
||||||
*/
|
*/
|
||||||
function setRightColor($colorIndex)
|
function setRightColor($colorIndex)
|
||||||
{
|
{
|
||||||
$this->_right_color = $colorIndex;
|
$this->_right_color = $colorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the cell's diagonal border color
|
* Sets the cell's diagonal border color
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param int $colorIndex Color index
|
* @param int $colorIndex Color index
|
||||||
*/
|
*/
|
||||||
function setDiagColor($colorIndex)
|
function setDiagColor($colorIndex)
|
||||||
{
|
{
|
||||||
$this->_diag_color = $colorIndex;
|
$this->_diag_color = $colorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the cell's foreground color
|
* Sets the cell's foreground color
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param int $colorIndex Color index
|
* @param int $colorIndex Color index
|
||||||
*/
|
*/
|
||||||
function setFgColor($colorIndex)
|
function setFgColor($colorIndex)
|
||||||
{
|
{
|
||||||
$this->_fg_color = $colorIndex;
|
$this->_fg_color = $colorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the cell's background color
|
* Sets the cell's background color
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param int $colorIndex Color index
|
* @param int $colorIndex Color index
|
||||||
*/
|
*/
|
||||||
function setBgColor($colorIndex)
|
function setBgColor($colorIndex)
|
||||||
{
|
{
|
||||||
$this->_bg_color = $colorIndex;
|
$this->_bg_color = $colorIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the index to the number format record
|
* Sets the index to the number format record
|
||||||
* It can be date, time, currency, etc...
|
* It can be date, time, currency, etc...
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param integer $numberFormatIndex Index to format record
|
* @param integer $numberFormatIndex Index to format record
|
||||||
*/
|
*/
|
||||||
function setNumberFormatIndex($numberFormatIndex)
|
function setNumberFormatIndex($numberFormatIndex)
|
||||||
{
|
{
|
||||||
$this->_numberFormatIndex = $numberFormatIndex;
|
$this->_numberFormatIndex = $numberFormatIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the font index.
|
* Set the font index.
|
||||||
*
|
*
|
||||||
* @param int $value Font index, note that value 4 does not exist
|
* @param int $value Font index, note that value 4 does not exist
|
||||||
*/
|
*/
|
||||||
public function setFontIndex($value)
|
public function setFontIndex($value)
|
||||||
{
|
{
|
||||||
$this->_fontIndex = $value;
|
$this->_fontIndex = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of BIFF2-BIFF8 codes for border styles
|
* Map of BIFF2-BIFF8 codes for border styles
|
||||||
* @static array of int
|
* @static array of int
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static $_mapBorderStyle = array ( PHPExcel_Style_Border::BORDER_NONE => 0x00,
|
private static $_mapBorderStyle = array ( PHPExcel_Style_Border::BORDER_NONE => 0x00,
|
||||||
PHPExcel_Style_Border::BORDER_THIN => 0x01,
|
PHPExcel_Style_Border::BORDER_THIN => 0x01,
|
||||||
PHPExcel_Style_Border::BORDER_MEDIUM => 0x02,
|
PHPExcel_Style_Border::BORDER_MEDIUM => 0x02,
|
||||||
PHPExcel_Style_Border::BORDER_DASHED => 0x03,
|
PHPExcel_Style_Border::BORDER_DASHED => 0x03,
|
||||||
PHPExcel_Style_Border::BORDER_DOTTED => 0x04,
|
PHPExcel_Style_Border::BORDER_DOTTED => 0x04,
|
||||||
PHPExcel_Style_Border::BORDER_THICK => 0x05,
|
PHPExcel_Style_Border::BORDER_THICK => 0x05,
|
||||||
PHPExcel_Style_Border::BORDER_DOUBLE => 0x06,
|
PHPExcel_Style_Border::BORDER_DOUBLE => 0x06,
|
||||||
PHPExcel_Style_Border::BORDER_HAIR => 0x07,
|
PHPExcel_Style_Border::BORDER_HAIR => 0x07,
|
||||||
PHPExcel_Style_Border::BORDER_MEDIUMDASHED => 0x08,
|
PHPExcel_Style_Border::BORDER_MEDIUMDASHED => 0x08,
|
||||||
PHPExcel_Style_Border::BORDER_DASHDOT => 0x09,
|
PHPExcel_Style_Border::BORDER_DASHDOT => 0x09,
|
||||||
PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT => 0x0A,
|
PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT => 0x0A,
|
||||||
PHPExcel_Style_Border::BORDER_DASHDOTDOT => 0x0B,
|
PHPExcel_Style_Border::BORDER_DASHDOTDOT => 0x0B,
|
||||||
PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT => 0x0C,
|
PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT => 0x0C,
|
||||||
PHPExcel_Style_Border::BORDER_SLANTDASHDOT => 0x0D,
|
PHPExcel_Style_Border::BORDER_SLANTDASHDOT => 0x0D,
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map border style
|
* Map border style
|
||||||
*
|
*
|
||||||
* @param string $borderStyle
|
* @param string $borderStyle
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private static function _mapBorderStyle($borderStyle) {
|
private static function _mapBorderStyle($borderStyle) {
|
||||||
if (isset(self::$_mapBorderStyle[$borderStyle]))
|
if (isset(self::$_mapBorderStyle[$borderStyle]))
|
||||||
return self::$_mapBorderStyle[$borderStyle];
|
return self::$_mapBorderStyle[$borderStyle];
|
||||||
return 0x00;
|
return 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of BIFF2-BIFF8 codes for fill types
|
* Map of BIFF2-BIFF8 codes for fill types
|
||||||
* @static array of int
|
* @static array of int
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static $_mapFillType = array( PHPExcel_Style_Fill::FILL_NONE => 0x00,
|
private static $_mapFillType = array( PHPExcel_Style_Fill::FILL_NONE => 0x00,
|
||||||
PHPExcel_Style_Fill::FILL_SOLID => 0x01,
|
PHPExcel_Style_Fill::FILL_SOLID => 0x01,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY => 0x02,
|
PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY => 0x02,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY => 0x03,
|
PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY => 0x03,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY => 0x04,
|
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY => 0x04,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05,
|
PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL => 0x06,
|
PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL => 0x06,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN => 0x07,
|
PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN => 0x07,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKUP => 0x08,
|
PHPExcel_Style_Fill::FILL_PATTERN_DARKUP => 0x08,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID => 0x09,
|
PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID => 0x09,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS => 0x0A,
|
PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS => 0x0A,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B,
|
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C,
|
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN => 0x0D,
|
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN => 0x0D,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP => 0x0E,
|
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP => 0x0E,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID => 0x0F,
|
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID => 0x0F,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10,
|
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_GRAY125 => 0x11,
|
PHPExcel_Style_Fill::FILL_PATTERN_GRAY125 => 0x11,
|
||||||
PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625 => 0x12,
|
PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625 => 0x12,
|
||||||
PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8
|
PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8
|
||||||
PHPExcel_Style_Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8
|
PHPExcel_Style_Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* Map fill type
|
* Map fill type
|
||||||
*
|
*
|
||||||
* @param string $fillType
|
* @param string $fillType
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private static function _mapFillType($fillType) {
|
private static function _mapFillType($fillType) {
|
||||||
if (isset(self::$_mapFillType[$fillType]))
|
if (isset(self::$_mapFillType[$fillType]))
|
||||||
return self::$_mapFillType[$fillType];
|
return self::$_mapFillType[$fillType];
|
||||||
return 0x00;
|
return 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of BIFF2-BIFF8 codes for horizontal alignment
|
* Map of BIFF2-BIFF8 codes for horizontal alignment
|
||||||
* @static array of int
|
* @static array of int
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static $_mapHAlign = array( PHPExcel_Style_Alignment::HORIZONTAL_GENERAL => 0,
|
private static $_mapHAlign = array( PHPExcel_Style_Alignment::HORIZONTAL_GENERAL => 0,
|
||||||
PHPExcel_Style_Alignment::HORIZONTAL_LEFT => 1,
|
PHPExcel_Style_Alignment::HORIZONTAL_LEFT => 1,
|
||||||
PHPExcel_Style_Alignment::HORIZONTAL_CENTER => 2,
|
PHPExcel_Style_Alignment::HORIZONTAL_CENTER => 2,
|
||||||
PHPExcel_Style_Alignment::HORIZONTAL_RIGHT => 3,
|
PHPExcel_Style_Alignment::HORIZONTAL_RIGHT => 3,
|
||||||
PHPExcel_Style_Alignment::HORIZONTAL_FILL => 4,
|
PHPExcel_Style_Alignment::HORIZONTAL_FILL => 4,
|
||||||
PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY => 5,
|
PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY => 5,
|
||||||
PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6,
|
PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6,
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* Map to BIFF2-BIFF8 codes for horizontal alignment
|
* Map to BIFF2-BIFF8 codes for horizontal alignment
|
||||||
*
|
*
|
||||||
* @param string $hAlign
|
* @param string $hAlign
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function _mapHAlign($hAlign)
|
private function _mapHAlign($hAlign)
|
||||||
{
|
{
|
||||||
if (isset(self::$_mapHAlign[$hAlign]))
|
if (isset(self::$_mapHAlign[$hAlign]))
|
||||||
return self::$_mapHAlign[$hAlign];
|
return self::$_mapHAlign[$hAlign];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of BIFF2-BIFF8 codes for vertical alignment
|
* Map of BIFF2-BIFF8 codes for vertical alignment
|
||||||
* @static array of int
|
* @static array of int
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static $_mapVAlign = array( PHPExcel_Style_Alignment::VERTICAL_TOP => 0,
|
private static $_mapVAlign = array( PHPExcel_Style_Alignment::VERTICAL_TOP => 0,
|
||||||
PHPExcel_Style_Alignment::VERTICAL_CENTER => 1,
|
PHPExcel_Style_Alignment::VERTICAL_CENTER => 1,
|
||||||
PHPExcel_Style_Alignment::VERTICAL_BOTTOM => 2,
|
PHPExcel_Style_Alignment::VERTICAL_BOTTOM => 2,
|
||||||
PHPExcel_Style_Alignment::VERTICAL_JUSTIFY => 3,
|
PHPExcel_Style_Alignment::VERTICAL_JUSTIFY => 3,
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* Map to BIFF2-BIFF8 codes for vertical alignment
|
* Map to BIFF2-BIFF8 codes for vertical alignment
|
||||||
*
|
*
|
||||||
* @param string $vAlign
|
* @param string $vAlign
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private static function _mapVAlign($vAlign) {
|
private static function _mapVAlign($vAlign) {
|
||||||
if (isset(self::$_mapVAlign[$vAlign]))
|
if (isset(self::$_mapVAlign[$vAlign]))
|
||||||
return self::$_mapVAlign[$vAlign];
|
return self::$_mapVAlign[$vAlign];
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map to BIFF8 codes for text rotation angle
|
* Map to BIFF8 codes for text rotation angle
|
||||||
*
|
*
|
||||||
* @param int $textRotation
|
* @param int $textRotation
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private static function _mapTextRotation($textRotation) {
|
private static function _mapTextRotation($textRotation) {
|
||||||
if ($textRotation >= 0) {
|
if ($textRotation >= 0) {
|
||||||
return $textRotation;
|
return $textRotation;
|
||||||
}
|
}
|
||||||
if ($textRotation == -165) {
|
if ($textRotation == -165) {
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
if ($textRotation < 0) {
|
if ($textRotation < 0) {
|
||||||
return 90 - $textRotation;
|
return 90 - $textRotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map locked
|
* Map locked
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private static function _mapLocked($locked) {
|
private static function _mapLocked($locked) {
|
||||||
switch ($locked) {
|
switch ($locked) {
|
||||||
case PHPExcel_Style_Protection::PROTECTION_INHERIT: return 1;
|
case PHPExcel_Style_Protection::PROTECTION_INHERIT: return 1;
|
||||||
case PHPExcel_Style_Protection::PROTECTION_PROTECTED: return 1;
|
case PHPExcel_Style_Protection::PROTECTION_PROTECTED: return 1;
|
||||||
case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED: return 0;
|
case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED: return 0;
|
||||||
default: return 1;
|
default: return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map hidden
|
* Map hidden
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private static function _mapHidden($hidden) {
|
private static function _mapHidden($hidden) {
|
||||||
switch ($hidden) {
|
switch ($hidden) {
|
||||||
case PHPExcel_Style_Protection::PROTECTION_INHERIT: return 0;
|
case PHPExcel_Style_Protection::PROTECTION_INHERIT: return 0;
|
||||||
case PHPExcel_Style_Protection::PROTECTION_PROTECTED: return 1;
|
case PHPExcel_Style_Protection::PROTECTION_PROTECTED: return 1;
|
||||||
case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED: return 0;
|
case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED: return 0;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_Exception
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,32 +22,25 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer
|
* @package PHPExcel_Writer
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
class PHPExcel_Writer_Exception extends PHPExcel_Exception
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Writer_Exception
|
* Error handler callback
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @param mixed $code
|
||||||
* @package PHPExcel_Writer
|
* @param mixed $string
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @param mixed $file
|
||||||
*/
|
* @param mixed $line
|
||||||
class PHPExcel_Writer_Exception extends PHPExcel_Exception {
|
* @param mixed $context
|
||||||
/**
|
*/
|
||||||
* Error handler callback
|
public static function errorHandlerCallback($code, $string, $file, $line, $context)
|
||||||
*
|
{
|
||||||
* @param mixed $code
|
$e = new self($string, $code);
|
||||||
* @param mixed $string
|
$e->line = $line;
|
||||||
* @param mixed $file
|
$e->file = $file;
|
||||||
* @param mixed $line
|
throw $e;
|
||||||
* @param mixed $context
|
}
|
||||||
*/
|
|
||||||
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
|
|
||||||
$e = new self($string, $code);
|
|
||||||
$e->line = $line;
|
|
||||||
$e->file = $file;
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_IWriter
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -24,15 +25,6 @@
|
|||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_IWriter
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
interface PHPExcel_Writer_IWriter
|
interface PHPExcel_Writer_IWriter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -41,6 +33,6 @@ interface PHPExcel_Writer_IWriter
|
|||||||
* @param string $pFilename Name of the file to save
|
* @param string $pFilename Name of the file to save
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function save($pFilename = NULL);
|
public function save($pFilename = null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_OpenDocument
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,20 +22,9 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
* @package PHPExcel_Writer_OpenDocument
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_OpenDocument
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
|
|
||||||
* @link http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os.html
|
|
||||||
*/
|
|
||||||
class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -42,14 +32,14 @@ class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements P
|
|||||||
*
|
*
|
||||||
* @var PHPExcel_Writer_OpenDocument_WriterPart[]
|
* @var PHPExcel_Writer_OpenDocument_WriterPart[]
|
||||||
*/
|
*/
|
||||||
private $_writerParts = array();
|
private $writerParts = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private PHPExcel
|
* Private PHPExcel
|
||||||
*
|
*
|
||||||
* @var PHPExcel
|
* @var PHPExcel
|
||||||
*/
|
*/
|
||||||
private $_spreadSheet;
|
private $spreadSheet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PHPExcel_Writer_OpenDocument
|
* Create a new PHPExcel_Writer_OpenDocument
|
||||||
@ -71,7 +61,7 @@ class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements P
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($writerPartsArray as $writer => $class) {
|
foreach ($writerPartsArray as $writer => $class) {
|
||||||
$this->_writerParts[$writer] = new $class($this);
|
$this->writerParts[$writer] = new $class($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,8 +73,8 @@ class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements P
|
|||||||
*/
|
*/
|
||||||
public function getWriterPart($pPartName = '')
|
public function getWriterPart($pPartName = '')
|
||||||
{
|
{
|
||||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
if ($pPartName != '' && isset($this->writerParts[strtolower($pPartName)])) {
|
||||||
return $this->_writerParts[strtolower($pPartName)];
|
return $this->writerParts[strtolower($pPartName)];
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -96,14 +86,14 @@ class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements P
|
|||||||
* @param string $pFilename
|
* @param string $pFilename
|
||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
*/
|
*/
|
||||||
public function save($pFilename = NULL)
|
public function save($pFilename = null)
|
||||||
{
|
{
|
||||||
if (!$this->_spreadSheet) {
|
if (!$this->spreadSheet) {
|
||||||
throw new PHPExcel_Writer_Exception('PHPExcel object unassigned.');
|
throw new PHPExcel_Writer_Exception('PHPExcel object unassigned.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// garbage collect
|
// garbage collect
|
||||||
$this->_spreadSheet->garbageCollect();
|
$this->spreadSheet->garbageCollect();
|
||||||
|
|
||||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||||
$originalFilename = $pFilename;
|
$originalFilename = $pFilename;
|
||||||
@ -114,15 +104,15 @@ class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$objZip = $this->_createZip($pFilename);
|
$objZip = $this->createZip($pFilename);
|
||||||
|
|
||||||
$objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('meta_inf')->writeManifest());
|
$objZip->addFromString('META-INF/manifest.xml', $this->getWriterPart('meta_inf')->writeManifest());
|
||||||
$objZip->addFromString('Thumbnails/thumbnail.png', $this->getWriterPart('thumbnails')->writeThumbnail());
|
$objZip->addFromString('Thumbnails/thumbnail.png', $this->getWriterPart('thumbnails')->writeThumbnail());
|
||||||
$objZip->addFromString('content.xml', $this->getWriterPart('content')->write());
|
$objZip->addFromString('content.xml', $this->getWriterPart('content')->write());
|
||||||
$objZip->addFromString('meta.xml', $this->getWriterPart('meta')->write());
|
$objZip->addFromString('meta.xml', $this->getWriterPart('meta')->write());
|
||||||
$objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->write());
|
$objZip->addFromString('mimetype', $this->getWriterPart('mimetype')->write());
|
||||||
$objZip->addFromString('settings.xml', $this->getWriterPart('settings')->write());
|
$objZip->addFromString('settings.xml', $this->getWriterPart('settings')->write());
|
||||||
$objZip->addFromString('styles.xml', $this->getWriterPart('styles')->write());
|
$objZip->addFromString('styles.xml', $this->getWriterPart('styles')->write());
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
if ($objZip->close() === false) {
|
if ($objZip->close() === false) {
|
||||||
@ -145,7 +135,7 @@ class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements P
|
|||||||
* @throws PHPExcel_Writer_Exception
|
* @throws PHPExcel_Writer_Exception
|
||||||
* @return ZipArchive
|
* @return ZipArchive
|
||||||
*/
|
*/
|
||||||
private function _createZip($pFilename)
|
private function createZip($pFilename)
|
||||||
{
|
{
|
||||||
// Create new ZIP file and open it for writing
|
// Create new ZIP file and open it for writing
|
||||||
$zipClass = PHPExcel_Settings::getZipClass();
|
$zipClass = PHPExcel_Settings::getZipClass();
|
||||||
@ -178,8 +168,8 @@ class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements P
|
|||||||
*/
|
*/
|
||||||
public function getPHPExcel()
|
public function getPHPExcel()
|
||||||
{
|
{
|
||||||
if ($this->_spreadSheet !== null) {
|
if ($this->spreadSheet !== null) {
|
||||||
return $this->_spreadSheet;
|
return $this->spreadSheet;
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Writer_Exception('No PHPExcel assigned.');
|
throw new PHPExcel_Writer_Exception('No PHPExcel assigned.');
|
||||||
}
|
}
|
||||||
@ -194,7 +184,7 @@ class PHPExcel_Writer_OpenDocument extends PHPExcel_Writer_Abstract implements P
|
|||||||
*/
|
*/
|
||||||
public function setPHPExcel(PHPExcel $pPHPExcel = null)
|
public function setPHPExcel(PHPExcel $pPHPExcel = null)
|
||||||
{
|
{
|
||||||
$this->_spreadSheet = $pPHPExcel;
|
$this->spreadSheet = $pPHPExcel;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_OpenDocument_Meta
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,19 +22,9 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
* @package PHPExcel_Writer_OpenDocument
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_OpenDocument_Meta
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
|
|
||||||
*/
|
|
||||||
class PHPExcel_Writer_OpenDocument_Meta extends PHPExcel_Writer_OpenDocument_WriterPart
|
class PHPExcel_Writer_OpenDocument_Meta extends PHPExcel_Writer_OpenDocument_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -61,36 +52,42 @@ class PHPExcel_Writer_OpenDocument_Meta extends PHPExcel_Writer_OpenDocument_Wri
|
|||||||
|
|
||||||
// Meta
|
// Meta
|
||||||
$objWriter->startElement('office:document-meta');
|
$objWriter->startElement('office:document-meta');
|
||||||
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
|
|
||||||
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
|
||||||
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
|
||||||
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
|
|
||||||
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
|
|
||||||
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
|
|
||||||
$objWriter->writeAttribute('office:version', '1.2');
|
|
||||||
|
|
||||||
$objWriter->startElement('office:meta');
|
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
|
||||||
$objWriter->writeElement('meta:initial-creator', $pPHPExcel->getProperties()->getCreator());
|
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||||
$objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
|
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
|
||||||
$objWriter->writeElement('meta:creation-date', date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
|
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
|
||||||
$objWriter->writeElement('dc:date', date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
|
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
|
||||||
$objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle());
|
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
|
||||||
$objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription());
|
$objWriter->writeAttribute('office:version', '1.2');
|
||||||
$objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject());
|
|
||||||
$keywords = explode(' ', $pPHPExcel->getProperties()->getKeywords());
|
$objWriter->startElement('office:meta');
|
||||||
foreach ($keywords as $keyword) {
|
|
||||||
$objWriter->writeElement('meta:keyword', $keyword);
|
$objWriter->writeElement('meta:initial-creator', $pPHPExcel->getProperties()->getCreator());
|
||||||
}
|
$objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
|
||||||
//<meta:document-statistic meta:table-count="XXX" meta:cell-count="XXX" meta:object-count="XXX"/>
|
$objWriter->writeElement('meta:creation-date', date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
|
||||||
$objWriter->startElement('meta:user-defined');
|
$objWriter->writeElement('dc:date', date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
|
||||||
$objWriter->writeAttribute('meta:name', 'Company');
|
$objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle());
|
||||||
$objWriter->writeRaw($pPHPExcel->getProperties()->getCompany());
|
$objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription());
|
||||||
$objWriter->endElement();
|
$objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject());
|
||||||
$objWriter->startElement('meta:user-defined');
|
$keywords = explode(' ', $pPHPExcel->getProperties()->getKeywords());
|
||||||
$objWriter->writeAttribute('meta:name', 'category');
|
foreach ($keywords as $keyword) {
|
||||||
$objWriter->writeRaw($pPHPExcel->getProperties()->getCategory());
|
$objWriter->writeElement('meta:keyword', $keyword);
|
||||||
$objWriter->endElement();
|
}
|
||||||
$objWriter->endElement();
|
|
||||||
|
//<meta:document-statistic meta:table-count="XXX" meta:cell-count="XXX" meta:object-count="XXX"/>
|
||||||
|
$objWriter->startElement('meta:user-defined');
|
||||||
|
$objWriter->writeAttribute('meta:name', 'Company');
|
||||||
|
$objWriter->writeRaw($pPHPExcel->getProperties()->getCompany());
|
||||||
|
$objWriter->endElement();
|
||||||
|
|
||||||
|
$objWriter->startElement('meta:user-defined');
|
||||||
|
$objWriter->writeAttribute('meta:name', 'category');
|
||||||
|
$objWriter->writeRaw($pPHPExcel->getProperties()->getCategory());
|
||||||
|
$objWriter->endElement();
|
||||||
|
|
||||||
|
$objWriter->endElement();
|
||||||
|
|
||||||
$objWriter->endElement();
|
$objWriter->endElement();
|
||||||
|
|
||||||
return $objWriter->getData();
|
return $objWriter->getData();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_OpenDocument_MetaInf
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,19 +22,9 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
* @package PHPExcel_Writer_OpenDocument
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_OpenDocument_MetaInf
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
|
|
||||||
*/
|
|
||||||
class PHPExcel_Writer_OpenDocument_MetaInf extends PHPExcel_Writer_OpenDocument_WriterPart
|
class PHPExcel_Writer_OpenDocument_MetaInf extends PHPExcel_Writer_OpenDocument_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* PHPExcel_Writer_OpenDocument_Mimetype
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -21,19 +22,9 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
* @package PHPExcel_Writer_OpenDocument
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_OpenDocument_Mimetype
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
|
|
||||||
*/
|
|
||||||
class PHPExcel_Writer_OpenDocument_Mimetype extends PHPExcel_Writer_OpenDocument_WriterPart
|
class PHPExcel_Writer_OpenDocument_Mimetype extends PHPExcel_Writer_OpenDocument_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_OpenDocument_Settings
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,19 +22,9 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
* @package PHPExcel_Writer_OpenDocument
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_OpenDocument_Settings
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
|
|
||||||
*/
|
|
||||||
class PHPExcel_Writer_OpenDocument_Settings extends PHPExcel_Writer_OpenDocument_WriterPart
|
class PHPExcel_Writer_OpenDocument_Settings extends PHPExcel_Writer_OpenDocument_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_OpenDocument_Styles
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,19 +22,9 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
* @package PHPExcel_Writer_OpenDocument
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_OpenDocument_Styles
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
|
|
||||||
*/
|
|
||||||
class PHPExcel_Writer_OpenDocument_Styles extends PHPExcel_Writer_OpenDocument_WriterPart
|
class PHPExcel_Writer_OpenDocument_Styles extends PHPExcel_Writer_OpenDocument_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_OpenDocument_Thumbnails
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,19 +22,9 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
* @package PHPExcel_Writer_OpenDocument
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_OpenDocument_Thumbnails
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
* @author Alexander Pervakov <frost-nzcr4@jagmort.com>
|
|
||||||
*/
|
|
||||||
class PHPExcel_Writer_OpenDocument_Thumbnails extends PHPExcel_Writer_OpenDocument_WriterPart
|
class PHPExcel_Writer_OpenDocument_Thumbnails extends PHPExcel_Writer_OpenDocument_WriterPart
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel
|
* PHPExcel_Writer_OpenDocument_WriterPart
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006 - 2015 PHPExcel
|
* Copyright (c) 2006 - 2015 PHPExcel
|
||||||
*
|
*
|
||||||
@ -21,18 +22,9 @@
|
|||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
* @package PHPExcel_Writer_OpenDocument
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* PHPExcel_Writer_OpenDocument_WriterPart
|
|
||||||
*
|
|
||||||
* @category PHPExcel
|
|
||||||
* @package PHPExcel_Writer_OpenDocument
|
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
|
||||||
*/
|
|
||||||
abstract class PHPExcel_Writer_OpenDocument_WriterPart extends PHPExcel_Writer_Excel2007_WriterPart
|
abstract class PHPExcel_Writer_OpenDocument_WriterPart extends PHPExcel_Writer_Excel2007_WriterPart
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user