You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
158
extend/phpexcel/PHPExcel/Writer/Abstract.php
Executable file
158
extend/phpexcel/PHPExcel/Writer/Abstract.php
Executable file
@ -0,0 +1,158 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Abstract
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Write charts that are defined in the workbook?
|
||||
* Identifies whether the Writer should write definitions for any charts that exist in the PHPExcel object;
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_includeCharts = FALSE;
|
||||
|
||||
/**
|
||||
* Pre-calculate formulas
|
||||
* 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
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_preCalculateFormulas = TRUE;
|
||||
|
||||
/**
|
||||
* Use disk caching where possible?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_useDiskCaching = FALSE;
|
||||
|
||||
/**
|
||||
* Disk caching directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_diskCachingDirectory = './';
|
||||
|
||||
/**
|
||||
* Write charts in workbook?
|
||||
* 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.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIncludeCharts() {
|
||||
return $this->_includeCharts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set write charts in workbook
|
||||
* 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.
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @return PHPExcel_Writer_IWriter
|
||||
*/
|
||||
public function setIncludeCharts($pValue = FALSE) {
|
||||
$this->_includeCharts = (boolean) $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Pre-Calculate Formulas flag
|
||||
* 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
|
||||
* viewer when opening the file
|
||||
* 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
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getPreCalculateFormulas() {
|
||||
return $this->_preCalculateFormulas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pre-Calculate Formulas
|
||||
* 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.
|
||||
*
|
||||
* @param boolean $pValue Pre-Calculate Formulas?
|
||||
* @return PHPExcel_Writer_IWriter
|
||||
*/
|
||||
public function setPreCalculateFormulas($pValue = TRUE) {
|
||||
$this->_preCalculateFormulas = (boolean) $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get use disk caching where possible?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getUseDiskCaching() {
|
||||
return $this->_useDiskCaching;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set use disk caching where possible?
|
||||
*
|
||||
* @param boolean $pValue
|
||||
* @param string $pDirectory Disk caching directory
|
||||
* @throws PHPExcel_Writer_Exception when directory does not exist
|
||||
* @return PHPExcel_Writer_Excel2007
|
||||
*/
|
||||
public function setUseDiskCaching($pValue = FALSE, $pDirectory = NULL) {
|
||||
$this->_useDiskCaching = $pValue;
|
||||
|
||||
if ($pDirectory !== NULL) {
|
||||
if (is_dir($pDirectory)) {
|
||||
$this->_diskCachingDirectory = $pDirectory;
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("Directory does not exist: $pDirectory");
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get disk caching directory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDiskCachingDirectory() {
|
||||
return $this->_diskCachingDirectory;
|
||||
}
|
||||
}
|
310
extend/phpexcel/PHPExcel/Writer/CSV.php
Executable file
310
extend/phpexcel/PHPExcel/Writer/CSV.php
Executable file
@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_CSV
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_CSV
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_CSV
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter {
|
||||
/**
|
||||
* PHPExcel object
|
||||
*
|
||||
* @var PHPExcel
|
||||
*/
|
||||
private $_phpExcel;
|
||||
|
||||
/**
|
||||
* Delimiter
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_delimiter = ',';
|
||||
|
||||
/**
|
||||
* Enclosure
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_enclosure = '"';
|
||||
|
||||
/**
|
||||
* Line ending
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_lineEnding = PHP_EOL;
|
||||
|
||||
/**
|
||||
* Sheet index to write
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_sheetIndex = 0;
|
||||
|
||||
/**
|
||||
* Whether to write a BOM (for UTF8).
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_useBOM = false;
|
||||
|
||||
/**
|
||||
* Whether to write a fully Excel compatible CSV file.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_excelCompatibility = false;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Writer_CSV
|
||||
*
|
||||
* @param PHPExcel $phpExcel PHPExcel object
|
||||
*/
|
||||
public function __construct(PHPExcel $phpExcel) {
|
||||
$this->_phpExcel = $phpExcel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPExcel to file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @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();
|
||||
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
|
||||
$saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
|
||||
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
|
||||
|
||||
// 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");
|
||||
fwrite($fileHandle, 'sep=' . $this->getDelimiter() . $this->_lineEnding);
|
||||
} elseif ($this->_useBOM) {
|
||||
// Write the UTF-8 BOM code if required
|
||||
fwrite($fileHandle, "\xEF\xBB\xBF");
|
||||
}
|
||||
|
||||
// Identify the range that we need to extract from the worksheet
|
||||
$maxCol = $sheet->getHighestDataColumn();
|
||||
$maxRow = $sheet->getHighestDataRow();
|
||||
|
||||
// Write rows to file
|
||||
for($row = 1; $row <= $maxRow; ++$row) {
|
||||
// Convert the row to an array...
|
||||
$cellsArray = $sheet->rangeToArray('A'.$row.':'.$maxCol.$row,'', $this->_preCalculateFormulas);
|
||||
// ... and write to the file
|
||||
$this->_writeLine($fileHandle, $cellsArray[0]);
|
||||
}
|
||||
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
PHPExcel_Calculation::setArrayReturnType($saveArrayReturnType);
|
||||
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get delimiter
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDelimiter() {
|
||||
return $this->_delimiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set delimiter
|
||||
*
|
||||
* @param string $pValue Delimiter, defaults to ,
|
||||
* @return PHPExcel_Writer_CSV
|
||||
*/
|
||||
public function setDelimiter($pValue = ',') {
|
||||
$this->_delimiter = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enclosure
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnclosure() {
|
||||
return $this->_enclosure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set enclosure
|
||||
*
|
||||
* @param string $pValue Enclosure, defaults to "
|
||||
* @return PHPExcel_Writer_CSV
|
||||
*/
|
||||
public function setEnclosure($pValue = '"') {
|
||||
if ($pValue == '') {
|
||||
$pValue = null;
|
||||
}
|
||||
$this->_enclosure = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get line ending
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLineEnding() {
|
||||
return $this->_lineEnding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line ending
|
||||
*
|
||||
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
|
||||
* @return PHPExcel_Writer_CSV
|
||||
*/
|
||||
public function setLineEnding($pValue = PHP_EOL) {
|
||||
$this->_lineEnding = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether BOM should be used
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getUseBOM() {
|
||||
return $this->_useBOM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether BOM should be used
|
||||
*
|
||||
* @param boolean $pValue Use UTF-8 byte-order mark? Defaults to false
|
||||
* @return PHPExcel_Writer_CSV
|
||||
*/
|
||||
public function setUseBOM($pValue = false) {
|
||||
$this->_useBOM = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the file should be saved with full Excel Compatibility
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getExcelCompatibility() {
|
||||
return $this->_excelCompatibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Note that this overrides other settings such as useBOM, enclosure and delimiter
|
||||
* @return PHPExcel_Writer_CSV
|
||||
*/
|
||||
public function setExcelCompatibility($pValue = false) {
|
||||
$this->_excelCompatibility = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sheet index
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSheetIndex() {
|
||||
return $this->_sheetIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sheet index
|
||||
*
|
||||
* @param int $pValue Sheet index
|
||||
* @return PHPExcel_Writer_CSV
|
||||
*/
|
||||
public function setSheetIndex($pValue = 0) {
|
||||
$this->_sheetIndex = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write line to CSV file
|
||||
*
|
||||
* @param mixed $pFileHandle PHP filehandle
|
||||
* @param array $pValues Array containing values in a row
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeLine($pFileHandle = null, $pValues = null) {
|
||||
if (is_array($pValues)) {
|
||||
// No leading delimiter
|
||||
$writeDelimiter = false;
|
||||
|
||||
// Build the line
|
||||
$line = '';
|
||||
|
||||
foreach ($pValues as $element) {
|
||||
// Escape enclosures
|
||||
$element = str_replace($this->_enclosure, $this->_enclosure . $this->_enclosure, $element);
|
||||
|
||||
// Add delimiter
|
||||
if ($writeDelimiter) {
|
||||
$line .= $this->_delimiter;
|
||||
} else {
|
||||
$writeDelimiter = true;
|
||||
}
|
||||
|
||||
// Add enclosed string
|
||||
$line .= $this->_enclosure . $element . $this->_enclosure;
|
||||
}
|
||||
|
||||
// Add line ending
|
||||
$line .= $this->_lineEnding;
|
||||
|
||||
// Write to file
|
||||
fwrite($pFileHandle, $line);
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("Invalid data row passed to CSV writer.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
532
extend/phpexcel/PHPExcel/Writer/Excel2007.php
Executable file
532
extend/phpexcel/PHPExcel/Writer/Excel2007.php
Executable file
@ -0,0 +1,532 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Pre-calculate formulas
|
||||
* 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
|
||||
*
|
||||
* Overrides the default TRUE for this specific writer for performance reasons
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_preCalculateFormulas = FALSE;
|
||||
|
||||
/**
|
||||
* Office2003 compatibility
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_office2003compatibility = false;
|
||||
|
||||
/**
|
||||
* Private writer parts
|
||||
*
|
||||
* @var PHPExcel_Writer_Excel2007_WriterPart[]
|
||||
*/
|
||||
private $_writerParts = array();
|
||||
|
||||
/**
|
||||
* Private PHPExcel
|
||||
*
|
||||
* @var PHPExcel
|
||||
*/
|
||||
private $_spreadSheet;
|
||||
|
||||
/**
|
||||
* Private string table
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $_stringTable = array();
|
||||
|
||||
/**
|
||||
* Private unique PHPExcel_Style_Conditional HashTable
|
||||
*
|
||||
* @var PHPExcel_HashTable
|
||||
*/
|
||||
private $_stylesConditionalHashTable;
|
||||
|
||||
/**
|
||||
* Private unique PHPExcel_Style HashTable
|
||||
*
|
||||
* @var PHPExcel_HashTable
|
||||
*/
|
||||
private $_styleHashTable;
|
||||
|
||||
/**
|
||||
* Private unique PHPExcel_Style_Fill HashTable
|
||||
*
|
||||
* @var PHPExcel_HashTable
|
||||
*/
|
||||
private $_fillHashTable;
|
||||
|
||||
/**
|
||||
* Private unique PHPExcel_Style_Font HashTable
|
||||
*
|
||||
* @var PHPExcel_HashTable
|
||||
*/
|
||||
private $_fontHashTable;
|
||||
|
||||
/**
|
||||
* Private unique PHPExcel_Style_Borders HashTable
|
||||
*
|
||||
* @var PHPExcel_HashTable
|
||||
*/
|
||||
private $_bordersHashTable ;
|
||||
|
||||
/**
|
||||
* Private unique PHPExcel_Style_NumberFormat HashTable
|
||||
*
|
||||
* @var PHPExcel_HashTable
|
||||
*/
|
||||
private $_numFmtHashTable;
|
||||
|
||||
/**
|
||||
* Private unique PHPExcel_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @var PHPExcel_HashTable
|
||||
*/
|
||||
private $_drawingHashTable;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Writer_Excel2007
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
*/
|
||||
public function __construct(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Assign PHPExcel
|
||||
$this->setPHPExcel($pPHPExcel);
|
||||
|
||||
$writerPartsArray = array( 'stringtable' => 'PHPExcel_Writer_Excel2007_StringTable',
|
||||
'contenttypes' => 'PHPExcel_Writer_Excel2007_ContentTypes',
|
||||
'docprops' => 'PHPExcel_Writer_Excel2007_DocProps',
|
||||
'rels' => 'PHPExcel_Writer_Excel2007_Rels',
|
||||
'theme' => 'PHPExcel_Writer_Excel2007_Theme',
|
||||
'style' => 'PHPExcel_Writer_Excel2007_Style',
|
||||
'workbook' => 'PHPExcel_Writer_Excel2007_Workbook',
|
||||
'worksheet' => 'PHPExcel_Writer_Excel2007_Worksheet',
|
||||
'drawing' => 'PHPExcel_Writer_Excel2007_Drawing',
|
||||
'comments' => 'PHPExcel_Writer_Excel2007_Comments',
|
||||
'chart' => 'PHPExcel_Writer_Excel2007_Chart',
|
||||
'relsvba' => 'PHPExcel_Writer_Excel2007_RelsVBA',
|
||||
'relsribbonobjects' => 'PHPExcel_Writer_Excel2007_RelsRibbon'
|
||||
);
|
||||
|
||||
// Initialise writer parts
|
||||
// and Assign their parent IWriters
|
||||
foreach ($writerPartsArray as $writer => $class) {
|
||||
$this->_writerParts[$writer] = new $class($this);
|
||||
}
|
||||
|
||||
$hashTablesArray = array( '_stylesConditionalHashTable', '_fillHashTable', '_fontHashTable',
|
||||
'_bordersHashTable', '_numFmtHashTable', '_drawingHashTable',
|
||||
'_styleHashTable'
|
||||
);
|
||||
|
||||
// Set HashTable variables
|
||||
foreach ($hashTablesArray as $tableName) {
|
||||
$this->$tableName = new PHPExcel_HashTable();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get writer part
|
||||
*
|
||||
* @param string $pPartName Writer part name
|
||||
* @return PHPExcel_Writer_Excel2007_WriterPart
|
||||
*/
|
||||
public function getWriterPart($pPartName = '') {
|
||||
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
|
||||
return $this->_writerParts[strtolower($pPartName)];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPExcel to file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function save($pFilename = null)
|
||||
{
|
||||
if ($this->_spreadSheet !== NULL) {
|
||||
// garbage collect
|
||||
$this->_spreadSheet->garbageCollect();
|
||||
|
||||
// If $pFilename is php://output or php://stdout, make it a temporary file...
|
||||
$originalFilename = $pFilename;
|
||||
if (strtolower($pFilename) == 'php://output' || strtolower($pFilename) == 'php://stdout') {
|
||||
$pFilename = @tempnam(PHPExcel_Shared_File::sys_get_temp_dir(), 'phpxltmp');
|
||||
if ($pFilename == '') {
|
||||
$pFilename = $originalFilename;
|
||||
}
|
||||
}
|
||||
|
||||
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->getWriteDebugLog();
|
||||
PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog(FALSE);
|
||||
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
|
||||
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
||||
|
||||
// Create string lookup table
|
||||
$this->_stringTable = array();
|
||||
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
|
||||
$this->_stringTable = $this->getWriterPart('StringTable')->createStringTable($this->_spreadSheet->getSheet($i), $this->_stringTable);
|
||||
}
|
||||
|
||||
// Create styles dictionaries
|
||||
$this->_styleHashTable->addFromSource( $this->getWriterPart('Style')->allStyles($this->_spreadSheet) );
|
||||
$this->_stylesConditionalHashTable->addFromSource( $this->getWriterPart('Style')->allConditionalStyles($this->_spreadSheet) );
|
||||
$this->_fillHashTable->addFromSource( $this->getWriterPart('Style')->allFills($this->_spreadSheet) );
|
||||
$this->_fontHashTable->addFromSource( $this->getWriterPart('Style')->allFonts($this->_spreadSheet) );
|
||||
$this->_bordersHashTable->addFromSource( $this->getWriterPart('Style')->allBorders($this->_spreadSheet) );
|
||||
$this->_numFmtHashTable->addFromSource( $this->getWriterPart('Style')->allNumberFormats($this->_spreadSheet) );
|
||||
|
||||
// Create drawing dictionary
|
||||
$this->_drawingHashTable->addFromSource( $this->getWriterPart('Drawing')->allDrawings($this->_spreadSheet) );
|
||||
|
||||
// Create new ZIP file and open it for writing
|
||||
$zipClass = PHPExcel_Settings::getZipClass();
|
||||
$objZip = new $zipClass();
|
||||
|
||||
// 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
|
||||
$ro = new ReflectionObject($objZip);
|
||||
$zipOverWrite = $ro->getConstant('OVERWRITE');
|
||||
$zipCreate = $ro->getConstant('CREATE');
|
||||
|
||||
if (file_exists($pFilename)) {
|
||||
unlink($pFilename);
|
||||
}
|
||||
// Try opening the ZIP file
|
||||
if ($objZip->open($pFilename, $zipOverWrite) !== true) {
|
||||
if ($objZip->open($pFilename, $zipCreate) !== true) {
|
||||
throw new PHPExcel_Writer_Exception("Could not open " . $pFilename . " for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
// Add [Content_Types].xml to ZIP file
|
||||
$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($this->_spreadSheet->hasMacros()){
|
||||
$macrosCode=$this->_spreadSheet->getMacrosCode();
|
||||
if(!is_null($macrosCode)){// we have the code ?
|
||||
$objZip->addFromString('xl/vbaProject.bin', $macrosCode);//allways in 'xl', allways named vbaProject.bin
|
||||
if($this->_spreadSheet->hasMacrosCertificate()){//signed macros ?
|
||||
// Yes : add the certificate file and the related rels file
|
||||
$objZip->addFromString('xl/vbaProjectSignature.bin', $this->_spreadSheet->getMacrosCertificate());
|
||||
$objZip->addFromString('xl/_rels/vbaProject.bin.rels',
|
||||
$this->getWriterPart('RelsVBA')->writeVBARelationships($this->_spreadSheet));
|
||||
}
|
||||
}
|
||||
}
|
||||
//a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels)
|
||||
if($this->_spreadSheet->hasRibbon()){
|
||||
$tmpRibbonTarget=$this->_spreadSheet->getRibbonXMLData('target');
|
||||
$objZip->addFromString($tmpRibbonTarget, $this->_spreadSheet->getRibbonXMLData('data'));
|
||||
if($this->_spreadSheet->hasRibbonBinObjects()){
|
||||
$tmpRootPath=dirname($tmpRibbonTarget).'/';
|
||||
$ribbonBinObjects=$this->_spreadSheet->getRibbonBinObjects('data');//the files to write
|
||||
foreach($ribbonBinObjects as $aPath=>$aContent){
|
||||
$objZip->addFromString($tmpRootPath.$aPath, $aContent);
|
||||
}
|
||||
//the rels for files
|
||||
$objZip->addFromString($tmpRootPath.'_rels/'.basename($tmpRibbonTarget).'.rels',
|
||||
$this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->_spreadSheet));
|
||||
}
|
||||
}
|
||||
|
||||
// Add relationships to ZIP file
|
||||
$objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_spreadSheet));
|
||||
$objZip->addFromString('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->_spreadSheet));
|
||||
|
||||
// Add document properties to ZIP file
|
||||
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet));
|
||||
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet));
|
||||
$customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->_spreadSheet);
|
||||
if ($customPropertiesPart !== NULL) {
|
||||
$objZip->addFromString('docProps/custom.xml', $customPropertiesPart);
|
||||
}
|
||||
|
||||
// Add theme to ZIP file
|
||||
$objZip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_spreadSheet));
|
||||
|
||||
// Add string table to ZIP file
|
||||
$objZip->addFromString('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->_stringTable));
|
||||
|
||||
// Add styles to ZIP file
|
||||
$objZip->addFromString('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->_spreadSheet));
|
||||
|
||||
// Add workbook to ZIP file
|
||||
$objZip->addFromString('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->_spreadSheet, $this->_preCalculateFormulas));
|
||||
|
||||
$chartCount = 0;
|
||||
// Add worksheets
|
||||
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));
|
||||
if ($this->_includeCharts) {
|
||||
$charts = $this->_spreadSheet->getSheet($i)->getChartCollection();
|
||||
if (count($charts) > 0) {
|
||||
foreach($charts as $chart) {
|
||||
$objZip->addFromString('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart));
|
||||
$chartCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$chartRef1 = $chartRef2 = 0;
|
||||
// Add worksheet relationships (drawings, ...)
|
||||
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
|
||||
|
||||
// Add relationships
|
||||
$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();
|
||||
$drawingCount = count($drawings);
|
||||
if ($this->_includeCharts) {
|
||||
$chartCount = $this->_spreadSheet->getSheet($i)->getChartCount();
|
||||
}
|
||||
|
||||
// Add drawing and image relationship parts
|
||||
if (($drawingCount > 0) || ($chartCount > 0)) {
|
||||
// Drawing relationships
|
||||
$objZip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->_spreadSheet->getSheet($i),$chartRef1, $this->_includeCharts));
|
||||
|
||||
// Drawings
|
||||
$objZip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->_spreadSheet->getSheet($i),$chartRef2,$this->_includeCharts));
|
||||
}
|
||||
|
||||
// Add comment relationship parts
|
||||
if (count($this->_spreadSheet->getSheet($i)->getComments()) > 0) {
|
||||
// VML Comments
|
||||
$objZip->addFromString('xl/drawings/vmlDrawing' . ($i + 1) . '.vml', $this->getWriterPart('Comments')->writeVMLComments($this->_spreadSheet->getSheet($i)));
|
||||
|
||||
// Comments
|
||||
$objZip->addFromString('xl/comments' . ($i + 1) . '.xml', $this->getWriterPart('Comments')->writeComments($this->_spreadSheet->getSheet($i)));
|
||||
}
|
||||
|
||||
// Add header/footer relationship parts
|
||||
if (count($this->_spreadSheet->getSheet($i)->getHeaderFooter()->getImages()) > 0) {
|
||||
// VML Drawings
|
||||
$objZip->addFromString('xl/drawings/vmlDrawingHF' . ($i + 1) . '.vml', $this->getWriterPart('Drawing')->writeVMLHeaderFooterImages($this->_spreadSheet->getSheet($i)));
|
||||
|
||||
// VML Drawing relationships
|
||||
$objZip->addFromString('xl/drawings/_rels/vmlDrawingHF' . ($i + 1) . '.vml.rels', $this->getWriterPart('Rels')->writeHeaderFooterDrawingRelationships($this->_spreadSheet->getSheet($i)));
|
||||
|
||||
// Media
|
||||
foreach ($this->_spreadSheet->getSheet($i)->getHeaderFooter()->getImages() as $image) {
|
||||
$objZip->addFromString('xl/media/' . $image->getIndexedFilename(), file_get_contents($image->getPath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add media
|
||||
for ($i = 0; $i < $this->getDrawingHashTable()->count(); ++$i) {
|
||||
if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
|
||||
$imageContents = null;
|
||||
$imagePath = $this->getDrawingHashTable()->getByIndex($i)->getPath();
|
||||
if (strpos($imagePath, 'zip://') !== false) {
|
||||
$imagePath = substr($imagePath, 6);
|
||||
$imagePathSplitted = explode('#', $imagePath);
|
||||
|
||||
$imageZip = new ZipArchive();
|
||||
$imageZip->open($imagePathSplitted[0]);
|
||||
$imageContents = $imageZip->getFromName($imagePathSplitted[1]);
|
||||
$imageZip->close();
|
||||
unset($imageZip);
|
||||
} else {
|
||||
$imageContents = file_get_contents($imagePath);
|
||||
}
|
||||
|
||||
$objZip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
} else if ($this->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
||||
ob_start();
|
||||
call_user_func(
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(),
|
||||
$this->getDrawingHashTable()->getByIndex($i)->getImageResource()
|
||||
);
|
||||
$imageContents = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$objZip->addFromString('xl/media/' . str_replace(' ', '_', $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()), $imageContents);
|
||||
}
|
||||
}
|
||||
|
||||
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
|
||||
PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
||||
|
||||
// Close file
|
||||
if ($objZip->close() === false) {
|
||||
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 ($originalFilename != $pFilename) {
|
||||
if (copy($pFilename, $originalFilename) === false) {
|
||||
throw new PHPExcel_Writer_Exception("Could not copy temporary zip file $pFilename to $originalFilename.");
|
||||
}
|
||||
@unlink($pFilename);
|
||||
}
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("PHPExcel object unassigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel object
|
||||
*
|
||||
* @return PHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function getPHPExcel() {
|
||||
if ($this->_spreadSheet !== null) {
|
||||
return $this->_spreadSheet;
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("No PHPExcel assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set PHPExcel object
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel PHPExcel object
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
* @return PHPExcel_Writer_Excel2007
|
||||
*/
|
||||
public function setPHPExcel(PHPExcel $pPHPExcel = null) {
|
||||
$this->_spreadSheet = $pPHPExcel;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get string table
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getStringTable() {
|
||||
return $this->_stringTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel_Style HashTable
|
||||
*
|
||||
* @return PHPExcel_HashTable
|
||||
*/
|
||||
public function getStyleHashTable() {
|
||||
return $this->_styleHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel_Style_Conditional HashTable
|
||||
*
|
||||
* @return PHPExcel_HashTable
|
||||
*/
|
||||
public function getStylesConditionalHashTable() {
|
||||
return $this->_stylesConditionalHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel_Style_Fill HashTable
|
||||
*
|
||||
* @return PHPExcel_HashTable
|
||||
*/
|
||||
public function getFillHashTable() {
|
||||
return $this->_fillHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel_Style_Font HashTable
|
||||
*
|
||||
* @return PHPExcel_HashTable
|
||||
*/
|
||||
public function getFontHashTable() {
|
||||
return $this->_fontHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel_Style_Borders HashTable
|
||||
*
|
||||
* @return PHPExcel_HashTable
|
||||
*/
|
||||
public function getBordersHashTable() {
|
||||
return $this->_bordersHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel_Style_NumberFormat HashTable
|
||||
*
|
||||
* @return PHPExcel_HashTable
|
||||
*/
|
||||
public function getNumFmtHashTable() {
|
||||
return $this->_numFmtHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PHPExcel_Worksheet_BaseDrawing HashTable
|
||||
*
|
||||
* @return PHPExcel_HashTable
|
||||
*/
|
||||
public function getDrawingHashTable() {
|
||||
return $this->_drawingHashTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Office2003 compatibility
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getOffice2003Compatibility() {
|
||||
return $this->_office2003compatibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Office2003 compatibility
|
||||
*
|
||||
* @param boolean $pValue Office2003 compatibility?
|
||||
* @return PHPExcel_Writer_Excel2007
|
||||
*/
|
||||
public function setOffice2003Compatibility($pValue = false) {
|
||||
$this->_office2003compatibility = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
1203
extend/phpexcel/PHPExcel/Writer/Excel2007/Chart.php
Executable file
1203
extend/phpexcel/PHPExcel/Writer/Excel2007/Chart.php
Executable file
File diff suppressed because it is too large
Load Diff
268
extend/phpexcel/PHPExcel/Writer/Excel2007/Comments.php
Executable file
268
extend/phpexcel/PHPExcel/Writer/Excel2007/Comments.php
Executable file
@ -0,0 +1,268 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_Comments
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write comments to XML format
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pWorksheet
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeComments(PHPExcel_Worksheet $pWorksheet = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Comments cache
|
||||
$comments = $pWorksheet->getComments();
|
||||
|
||||
// Authors cache
|
||||
$authors = array();
|
||||
$authorId = 0;
|
||||
foreach ($comments as $comment) {
|
||||
if (!isset($authors[$comment->getAuthor()])) {
|
||||
$authors[$comment->getAuthor()] = $authorId++;
|
||||
}
|
||||
}
|
||||
|
||||
// comments
|
||||
$objWriter->startElement('comments');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
||||
|
||||
// Loop through authors
|
||||
$objWriter->startElement('authors');
|
||||
foreach ($authors as $author => $index) {
|
||||
$objWriter->writeElement('author', $author);
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// Loop through comments
|
||||
$objWriter->startElement('commentList');
|
||||
foreach ($comments as $key => $value) {
|
||||
$this->_writeComment($objWriter, $key, $value, $authors);
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write comment to XML format
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pCellReference Cell reference
|
||||
* @param PHPExcel_Comment $pComment Comment
|
||||
* @param array $pAuthors Array of authors
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function _writeComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null, $pAuthors = null)
|
||||
{
|
||||
// comment
|
||||
$objWriter->startElement('comment');
|
||||
$objWriter->writeAttribute('ref', $pCellReference);
|
||||
$objWriter->writeAttribute('authorId', $pAuthors[$pComment->getAuthor()]);
|
||||
|
||||
// text
|
||||
$objWriter->startElement('text');
|
||||
$this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $pComment->getText());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write VML comments to XML format
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pWorksheet
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeVMLComments(PHPExcel_Worksheet $pWorksheet = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Comments cache
|
||||
$comments = $pWorksheet->getComments();
|
||||
|
||||
// xml
|
||||
$objWriter->startElement('xml');
|
||||
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
|
||||
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
|
||||
$objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
|
||||
|
||||
// o:shapelayout
|
||||
$objWriter->startElement('o:shapelayout');
|
||||
$objWriter->writeAttribute('v:ext', 'edit');
|
||||
|
||||
// o:idmap
|
||||
$objWriter->startElement('o:idmap');
|
||||
$objWriter->writeAttribute('v:ext', 'edit');
|
||||
$objWriter->writeAttribute('data', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:shapetype
|
||||
$objWriter->startElement('v:shapetype');
|
||||
$objWriter->writeAttribute('id', '_x0000_t202');
|
||||
$objWriter->writeAttribute('coordsize', '21600,21600');
|
||||
$objWriter->writeAttribute('o:spt', '202');
|
||||
$objWriter->writeAttribute('path', 'm,l,21600r21600,l21600,xe');
|
||||
|
||||
// v:stroke
|
||||
$objWriter->startElement('v:stroke');
|
||||
$objWriter->writeAttribute('joinstyle', 'miter');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:path
|
||||
$objWriter->startElement('v:path');
|
||||
$objWriter->writeAttribute('gradientshapeok', 't');
|
||||
$objWriter->writeAttribute('o:connecttype', 'rect');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Loop through comments
|
||||
foreach ($comments as $key => $value) {
|
||||
$this->_writeVMLComment($objWriter, $key, $value);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write VML comment to XML format
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pCellReference Cell reference
|
||||
* @param PHPExcel_Comment $pComment Comment
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function _writeVMLComment(PHPExcel_Shared_XMLWriter $objWriter = null, $pCellReference = 'A1', PHPExcel_Comment $pComment = null)
|
||||
{
|
||||
// Metadata
|
||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($pCellReference);
|
||||
$column = PHPExcel_Cell::columnIndexFromString($column);
|
||||
$id = 1024 + $column + $row;
|
||||
$id = substr($id, 0, 4);
|
||||
|
||||
// v:shape
|
||||
$objWriter->startElement('v:shape');
|
||||
$objWriter->writeAttribute('id', '_x0000_s' . $id);
|
||||
$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('fillcolor', '#' . $pComment->getFillColor()->getRGB());
|
||||
$objWriter->writeAttribute('o:insetmode', 'auto');
|
||||
|
||||
// v:fill
|
||||
$objWriter->startElement('v:fill');
|
||||
$objWriter->writeAttribute('color2', '#' . $pComment->getFillColor()->getRGB());
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:shadow
|
||||
$objWriter->startElement('v:shadow');
|
||||
$objWriter->writeAttribute('on', 't');
|
||||
$objWriter->writeAttribute('color', 'black');
|
||||
$objWriter->writeAttribute('obscured', 't');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:path
|
||||
$objWriter->startElement('v:path');
|
||||
$objWriter->writeAttribute('o:connecttype', 'none');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:textbox
|
||||
$objWriter->startElement('v:textbox');
|
||||
$objWriter->writeAttribute('style', 'mso-direction-alt:auto');
|
||||
|
||||
// div
|
||||
$objWriter->startElement('div');
|
||||
$objWriter->writeAttribute('style', 'text-align:left');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// x:ClientData
|
||||
$objWriter->startElement('x:ClientData');
|
||||
$objWriter->writeAttribute('ObjectType', 'Note');
|
||||
|
||||
// x:MoveWithCells
|
||||
$objWriter->writeElement('x:MoveWithCells', '');
|
||||
|
||||
// x:SizeWithCells
|
||||
$objWriter->writeElement('x:SizeWithCells', '');
|
||||
|
||||
// x:Anchor
|
||||
//$objWriter->writeElement('x:Anchor', $column . ', 15, ' . ($row - 2) . ', 10, ' . ($column + 4) . ', 15, ' . ($row + 5) . ', 18');
|
||||
|
||||
// x:AutoFill
|
||||
$objWriter->writeElement('x:AutoFill', 'False');
|
||||
|
||||
// x:Row
|
||||
$objWriter->writeElement('x:Row', ($row - 1));
|
||||
|
||||
// x:Column
|
||||
$objWriter->writeElement('x:Column', ($column - 1));
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
287
extend/phpexcel/PHPExcel/Writer/Excel2007/ContentTypes.php
Executable file
287
extend/phpexcel/PHPExcel/Writer/Excel2007/ContentTypes.php
Executable file
@ -0,0 +1,287 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_ContentTypes
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write content types to XML format
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @param boolean $includeCharts Flag indicating if we should include drawing details for charts
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeContentTypes(PHPExcel $pPHPExcel = null, $includeCharts = FALSE)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Types
|
||||
$objWriter->startElement('Types');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
|
||||
|
||||
// Theme
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/xl/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
|
||||
);
|
||||
|
||||
// Styles
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/xl/styles.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'
|
||||
);
|
||||
|
||||
// Rels
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
|
||||
);
|
||||
|
||||
// XML
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'xml', 'application/xml'
|
||||
);
|
||||
|
||||
// VML
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing'
|
||||
);
|
||||
|
||||
// Workbook
|
||||
if($pPHPExcel->hasMacros()){ //Macros in workbook ?
|
||||
// Yes : not standard content but "macroEnabled"
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/xl/workbook.xml', 'application/vnd.ms-excel.sheet.macroEnabled.main+xml'
|
||||
);
|
||||
//... and define a new type for the VBA project
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, 'bin', 'application/vnd.ms-office.vbaProject'
|
||||
);
|
||||
if($pPHPExcel->hasMacrosCertificate()){// signed macros ?
|
||||
// Yes : add needed information
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/xl/vbaProjectSignature.bin', 'application/vnd.ms-office.vbaProjectSignature'
|
||||
);
|
||||
}
|
||||
}else{// no macros in workbook, so standard type
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'
|
||||
);
|
||||
}
|
||||
|
||||
// DocProps
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
|
||||
);
|
||||
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
|
||||
);
|
||||
|
||||
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
||||
if (!empty($customPropertyList)) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml'
|
||||
);
|
||||
}
|
||||
|
||||
// Worksheets
|
||||
$sheetCount = $pPHPExcel->getSheetCount();
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/xl/worksheets/sheet' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'
|
||||
);
|
||||
}
|
||||
|
||||
// Shared strings
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'
|
||||
);
|
||||
|
||||
// Add worksheet relationship content types
|
||||
$chart = 1;
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
$drawings = $pPHPExcel->getSheet($i)->getDrawingCollection();
|
||||
$drawingCount = count($drawings);
|
||||
$chartCount = ($includeCharts) ? $pPHPExcel->getSheet($i)->getChartCount() : 0;
|
||||
|
||||
// We need a drawing relationship for the worksheet if we have either drawings or charts
|
||||
if (($drawingCount > 0) || ($chartCount > 0)) {
|
||||
$this->_writeOverrideContentType(
|
||||
$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 ($chartCount > 0) {
|
||||
for ($c = 0; $c < $chartCount; ++$c) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/xl/charts/chart' . $chart++ . '.xml', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Comments
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
if (count($pPHPExcel->getSheet($i)->getComments()) > 0) {
|
||||
$this->_writeOverrideContentType(
|
||||
$objWriter, '/xl/comments' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Add media content-types
|
||||
$aMediaContentTypes = array();
|
||||
$mediaCount = $this->getParentWriter()->getDrawingHashTable()->count();
|
||||
for ($i = 0; $i < $mediaCount; ++$i) {
|
||||
$extension = '';
|
||||
$mimeType = '';
|
||||
|
||||
if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_Drawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getExtension());
|
||||
$mimeType = $this->_getImageMimeType( $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getPath() );
|
||||
} else if ($this->getParentWriter()->getDrawingHashTable()->getByIndex($i) instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
||||
$extension = strtolower($this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType());
|
||||
$extension = explode('/', $extension);
|
||||
$extension = $extension[1];
|
||||
|
||||
$mimeType = $this->getParentWriter()->getDrawingHashTable()->getByIndex($i)->getMimeType();
|
||||
}
|
||||
|
||||
if (!isset( $aMediaContentTypes[$extension]) ) {
|
||||
$aMediaContentTypes[$extension] = $mimeType;
|
||||
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, $extension, $mimeType
|
||||
);
|
||||
}
|
||||
}
|
||||
if($pPHPExcel->hasRibbonBinObjects()){//Some additional objects in the ribbon ?
|
||||
//we need to write "Extension" but not already write for media content
|
||||
$tabRibbonTypes=array_diff($pPHPExcel->getRibbonBinObjects('types'), array_keys($aMediaContentTypes));
|
||||
foreach($tabRibbonTypes as $aRibbonType){
|
||||
$mimeType='image/.'.$aRibbonType;//we wrote $mimeType like customUI Editor
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, $aRibbonType, $mimeType
|
||||
);
|
||||
}
|
||||
}
|
||||
$sheetCount = $pPHPExcel->getSheetCount();
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) {
|
||||
foreach ($pPHPExcel->getSheet()->getHeaderFooter()->getImages() as $image) {
|
||||
if (!isset( $aMediaContentTypes[strtolower($image->getExtension())]) ) {
|
||||
$aMediaContentTypes[strtolower($image->getExtension())] = $this->_getImageMimeType( $image->getPath() );
|
||||
|
||||
$this->_writeDefaultContentType(
|
||||
$objWriter, strtolower($image->getExtension()), $aMediaContentTypes[strtolower($image->getExtension())]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image mime type
|
||||
*
|
||||
* @param string $pFile Filename
|
||||
* @return string Mime Type
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _getImageMimeType($pFile = '')
|
||||
{
|
||||
if (PHPExcel_Shared_File::file_exists($pFile)) {
|
||||
$image = getimagesize($pFile);
|
||||
return image_type_to_mime_type($image[2]);
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("File $pFile does not exist");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Default content type
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeDefaultContentType(PHPExcel_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Default');
|
||||
$objWriter->writeAttribute('Extension', $pPartname);
|
||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pPartname Part name
|
||||
* @param string $pContentType Content type
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeOverrideContentType(PHPExcel_Shared_XMLWriter $objWriter = null, $pPartname = '', $pContentType = '')
|
||||
{
|
||||
if ($pPartname != '' && $pContentType != '') {
|
||||
// Write content type
|
||||
$objWriter->startElement('Override');
|
||||
$objWriter->writeAttribute('PartName', $pPartname);
|
||||
$objWriter->writeAttribute('ContentType', $pContentType);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
}
|
272
extend/phpexcel/PHPExcel/Writer/Excel2007/DocProps.php
Executable file
272
extend/phpexcel/PHPExcel/Writer/Excel2007/DocProps.php
Executable file
@ -0,0 +1,272 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_DocProps
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write docProps/app.xml to XML format
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeDocPropsApp(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Properties
|
||||
$objWriter->startElement('Properties');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
|
||||
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
||||
|
||||
// Application
|
||||
$objWriter->writeElement('Application', 'Microsoft Excel');
|
||||
|
||||
// DocSecurity
|
||||
$objWriter->writeElement('DocSecurity', '0');
|
||||
|
||||
// ScaleCrop
|
||||
$objWriter->writeElement('ScaleCrop', 'false');
|
||||
|
||||
// HeadingPairs
|
||||
$objWriter->startElement('HeadingPairs');
|
||||
|
||||
// Vector
|
||||
$objWriter->startElement('vt:vector');
|
||||
$objWriter->writeAttribute('size', '2');
|
||||
$objWriter->writeAttribute('baseType', 'variant');
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:lpstr', 'Worksheets');
|
||||
$objWriter->endElement();
|
||||
|
||||
// Variant
|
||||
$objWriter->startElement('vt:variant');
|
||||
$objWriter->writeElement('vt:i4', $pPHPExcel->getSheetCount());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// TitlesOfParts
|
||||
$objWriter->startElement('TitlesOfParts');
|
||||
|
||||
// Vector
|
||||
$objWriter->startElement('vt:vector');
|
||||
$objWriter->writeAttribute('size', $pPHPExcel->getSheetCount());
|
||||
$objWriter->writeAttribute('baseType', 'lpstr');
|
||||
|
||||
$sheetCount = $pPHPExcel->getSheetCount();
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
$objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle());
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Company
|
||||
$objWriter->writeElement('Company', $pPHPExcel->getProperties()->getCompany());
|
||||
|
||||
// Company
|
||||
$objWriter->writeElement('Manager', $pPHPExcel->getProperties()->getManager());
|
||||
|
||||
// LinksUpToDate
|
||||
$objWriter->writeElement('LinksUpToDate', 'false');
|
||||
|
||||
// SharedDoc
|
||||
$objWriter->writeElement('SharedDoc', 'false');
|
||||
|
||||
// HyperlinksChanged
|
||||
$objWriter->writeElement('HyperlinksChanged', 'false');
|
||||
|
||||
// AppVersion
|
||||
$objWriter->writeElement('AppVersion', '12.0000');
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write docProps/core.xml to XML format
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeDocPropsCore(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// cp:coreProperties
|
||||
$objWriter->startElement('cp:coreProperties');
|
||||
$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:dcterms', 'http://purl.org/dc/terms/');
|
||||
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
|
||||
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||
|
||||
// dc:creator
|
||||
$objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
|
||||
|
||||
// cp:lastModifiedBy
|
||||
$objWriter->writeElement('cp:lastModifiedBy', $pPHPExcel->getProperties()->getLastModifiedBy());
|
||||
|
||||
// dcterms:created
|
||||
$objWriter->startElement('dcterms:created');
|
||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||
$objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// dcterms:modified
|
||||
$objWriter->startElement('dcterms:modified');
|
||||
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
|
||||
$objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getModified()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// dc:title
|
||||
$objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle());
|
||||
|
||||
// dc:description
|
||||
$objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription());
|
||||
|
||||
// dc:subject
|
||||
$objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject());
|
||||
|
||||
// cp:keywords
|
||||
$objWriter->writeElement('cp:keywords', $pPHPExcel->getProperties()->getKeywords());
|
||||
|
||||
// cp:category
|
||||
$objWriter->writeElement('cp:category', $pPHPExcel->getProperties()->getCategory());
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write docProps/custom.xml to XML format
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeDocPropsCustom(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
||||
if (empty($customPropertyList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// cp:coreProperties
|
||||
$objWriter->startElement('Properties');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
|
||||
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
|
||||
|
||||
|
||||
foreach($customPropertyList as $key => $customProperty) {
|
||||
$propertyValue = $pPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
|
||||
$propertyType = $pPHPExcel->getProperties()->getCustomPropertyType($customProperty);
|
||||
|
||||
$objWriter->startElement('property');
|
||||
$objWriter->writeAttribute('fmtid', '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}');
|
||||
$objWriter->writeAttribute('pid', $key+2);
|
||||
$objWriter->writeAttribute('name', $customProperty);
|
||||
|
||||
switch($propertyType) {
|
||||
case 'i' :
|
||||
$objWriter->writeElement('vt:i4', $propertyValue);
|
||||
break;
|
||||
case 'f' :
|
||||
$objWriter->writeElement('vt:r8', $propertyValue);
|
||||
break;
|
||||
case 'b' :
|
||||
$objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false');
|
||||
break;
|
||||
case 'd' :
|
||||
$objWriter->startElement('vt:filetime');
|
||||
$objWriter->writeRawData(date(DATE_W3C, $propertyValue));
|
||||
$objWriter->endElement();
|
||||
break;
|
||||
default :
|
||||
$objWriter->writeElement('vt:lpwstr', $propertyValue);
|
||||
break;
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
}
|
598
extend/phpexcel/PHPExcel/Writer/Excel2007/Drawing.php
Executable file
598
extend/phpexcel/PHPExcel/Writer/Excel2007/Drawing.php
Executable file
@ -0,0 +1,598 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_Drawing
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write drawings to XML format
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pWorksheet
|
||||
* @param int &$chartRef Chart ID
|
||||
* @param boolean $includeCharts Flag indicating if we should include drawing details for charts
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeDrawings(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = FALSE)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// xdr:wsDr
|
||||
$objWriter->startElement('xdr:wsDr');
|
||||
$objWriter->writeAttribute('xmlns:xdr', 'http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing');
|
||||
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
|
||||
|
||||
// Loop through images and write drawings
|
||||
$i = 1;
|
||||
$iterator = $pWorksheet->getDrawingCollection()->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
$this->_writeDrawing($objWriter, $iterator->current(), $i);
|
||||
|
||||
$iterator->next();
|
||||
++$i;
|
||||
}
|
||||
|
||||
if ($includeCharts) {
|
||||
$chartCount = $pWorksheet->getChartCount();
|
||||
// Loop through charts and write the chart position
|
||||
if ($chartCount > 0) {
|
||||
for ($c = 0; $c < $chartCount; ++$c) {
|
||||
$this->_writeChart($objWriter, $pWorksheet->getChartByIndex($c), $c+$i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write drawings to XML format
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Chart $pChart
|
||||
* @param int $pRelationId
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function _writeChart(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Chart $pChart = null, $pRelationId = -1)
|
||||
{
|
||||
$tl = $pChart->getTopLeftPosition();
|
||||
$tl['colRow'] = PHPExcel_Cell::coordinateFromString($tl['cell']);
|
||||
$br = $pChart->getBottomRightPosition();
|
||||
$br['colRow'] = PHPExcel_Cell::coordinateFromString($br['cell']);
|
||||
|
||||
$objWriter->startElement('xdr:twoCellAnchor');
|
||||
|
||||
$objWriter->startElement('xdr:from');
|
||||
$objWriter->writeElement('xdr:col', PHPExcel_Cell::columnIndexFromString($tl['colRow'][0]) - 1);
|
||||
$objWriter->writeElement('xdr:colOff', PHPExcel_Shared_Drawing::pixelsToEMU($tl['xOffset']));
|
||||
$objWriter->writeElement('xdr:row', $tl['colRow'][1] - 1);
|
||||
$objWriter->writeElement('xdr:rowOff', PHPExcel_Shared_Drawing::pixelsToEMU($tl['yOffset']));
|
||||
$objWriter->endElement();
|
||||
$objWriter->startElement('xdr:to');
|
||||
$objWriter->writeElement('xdr:col', PHPExcel_Cell::columnIndexFromString($br['colRow'][0]) - 1);
|
||||
$objWriter->writeElement('xdr:colOff', PHPExcel_Shared_Drawing::pixelsToEMU($br['xOffset']));
|
||||
$objWriter->writeElement('xdr:row', $br['colRow'][1] - 1);
|
||||
$objWriter->writeElement('xdr:rowOff', PHPExcel_Shared_Drawing::pixelsToEMU($br['yOffset']));
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('xdr:graphicFrame');
|
||||
$objWriter->writeAttribute('macro', '');
|
||||
$objWriter->startElement('xdr:nvGraphicFramePr');
|
||||
$objWriter->startElement('xdr:cNvPr');
|
||||
$objWriter->writeAttribute('name', 'Chart '.$pRelationId);
|
||||
$objWriter->writeAttribute('id', 1025 * $pRelationId);
|
||||
$objWriter->endElement();
|
||||
$objWriter->startElement('xdr:cNvGraphicFramePr');
|
||||
$objWriter->startElement('a:graphicFrameLocks');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('xdr:xfrm');
|
||||
$objWriter->startElement('a:off');
|
||||
$objWriter->writeAttribute('x', '0');
|
||||
$objWriter->writeAttribute('y', '0');
|
||||
$objWriter->endElement();
|
||||
$objWriter->startElement('a:ext');
|
||||
$objWriter->writeAttribute('cx', '0');
|
||||
$objWriter->writeAttribute('cy', '0');
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('a:graphic');
|
||||
$objWriter->startElement('a:graphicData');
|
||||
$objWriter->writeAttribute('uri', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
|
||||
$objWriter->startElement('c:chart');
|
||||
$objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart');
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('r:id', 'rId'.$pRelationId);
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->startElement('xdr:clientData');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write drawings to XML format
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Worksheet_BaseDrawing $pDrawing
|
||||
* @param int $pRelationId
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function _writeDrawing(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet_BaseDrawing $pDrawing = null, $pRelationId = -1)
|
||||
{
|
||||
if ($pRelationId >= 0) {
|
||||
// xdr:oneCellAnchor
|
||||
$objWriter->startElement('xdr:oneCellAnchor');
|
||||
// Image location
|
||||
$aCoordinates = PHPExcel_Cell::coordinateFromString($pDrawing->getCoordinates());
|
||||
$aCoordinates[0] = PHPExcel_Cell::columnIndexFromString($aCoordinates[0]);
|
||||
|
||||
// xdr:from
|
||||
$objWriter->startElement('xdr:from');
|
||||
$objWriter->writeElement('xdr:col', $aCoordinates[0] - 1);
|
||||
$objWriter->writeElement('xdr:colOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetX()));
|
||||
$objWriter->writeElement('xdr:row', $aCoordinates[1] - 1);
|
||||
$objWriter->writeElement('xdr:rowOff', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getOffsetY()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// xdr:ext
|
||||
$objWriter->startElement('xdr:ext');
|
||||
$objWriter->writeAttribute('cx', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getWidth()));
|
||||
$objWriter->writeAttribute('cy', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getHeight()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// xdr:pic
|
||||
$objWriter->startElement('xdr:pic');
|
||||
|
||||
// xdr:nvPicPr
|
||||
$objWriter->startElement('xdr:nvPicPr');
|
||||
|
||||
// xdr:cNvPr
|
||||
$objWriter->startElement('xdr:cNvPr');
|
||||
$objWriter->writeAttribute('id', $pRelationId);
|
||||
$objWriter->writeAttribute('name', $pDrawing->getName());
|
||||
$objWriter->writeAttribute('descr', $pDrawing->getDescription());
|
||||
$objWriter->endElement();
|
||||
|
||||
// xdr:cNvPicPr
|
||||
$objWriter->startElement('xdr:cNvPicPr');
|
||||
|
||||
// a:picLocks
|
||||
$objWriter->startElement('a:picLocks');
|
||||
$objWriter->writeAttribute('noChangeAspect', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// xdr:blipFill
|
||||
$objWriter->startElement('xdr:blipFill');
|
||||
|
||||
// a:blip
|
||||
$objWriter->startElement('a:blip');
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
$objWriter->writeAttribute('r:embed', 'rId' . $pRelationId);
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:stretch
|
||||
$objWriter->startElement('a:stretch');
|
||||
$objWriter->writeElement('a:fillRect', null);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// xdr:spPr
|
||||
$objWriter->startElement('xdr:spPr');
|
||||
|
||||
// a:xfrm
|
||||
$objWriter->startElement('a:xfrm');
|
||||
$objWriter->writeAttribute('rot', PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getRotation()));
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:prstGeom
|
||||
$objWriter->startElement('a:prstGeom');
|
||||
$objWriter->writeAttribute('prst', 'rect');
|
||||
|
||||
// a:avLst
|
||||
$objWriter->writeElement('a:avLst', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// // a:solidFill
|
||||
// $objWriter->startElement('a:solidFill');
|
||||
|
||||
// // a:srgbClr
|
||||
// $objWriter->startElement('a:srgbClr');
|
||||
// $objWriter->writeAttribute('val', 'FFFFFF');
|
||||
|
||||
///* SHADE
|
||||
// // a:shade
|
||||
// $objWriter->startElement('a:shade');
|
||||
// $objWriter->writeAttribute('val', '85000');
|
||||
// $objWriter->endElement();
|
||||
//*/
|
||||
|
||||
// $objWriter->endElement();
|
||||
|
||||
// $objWriter->endElement();
|
||||
/*
|
||||
// a:ln
|
||||
$objWriter->startElement('a:ln');
|
||||
$objWriter->writeAttribute('w', '88900');
|
||||
$objWriter->writeAttribute('cap', 'sq');
|
||||
|
||||
// a:solidFill
|
||||
$objWriter->startElement('a:solidFill');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', 'FFFFFF');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:miter
|
||||
$objWriter->startElement('a:miter');
|
||||
$objWriter->writeAttribute('lim', '800000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
*/
|
||||
|
||||
if ($pDrawing->getShadow()->getVisible()) {
|
||||
// a:effectLst
|
||||
$objWriter->startElement('a:effectLst');
|
||||
|
||||
// a:outerShdw
|
||||
$objWriter->startElement('a:outerShdw');
|
||||
$objWriter->writeAttribute('blurRad', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getBlurRadius()));
|
||||
$objWriter->writeAttribute('dist', PHPExcel_Shared_Drawing::pixelsToEMU($pDrawing->getShadow()->getDistance()));
|
||||
$objWriter->writeAttribute('dir', PHPExcel_Shared_Drawing::degreesToAngle($pDrawing->getShadow()->getDirection()));
|
||||
$objWriter->writeAttribute('algn', $pDrawing->getShadow()->getAlignment());
|
||||
$objWriter->writeAttribute('rotWithShape', '0');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', $pDrawing->getShadow()->getColor()->getRGB());
|
||||
|
||||
// a:alpha
|
||||
$objWriter->startElement('a:alpha');
|
||||
$objWriter->writeAttribute('val', $pDrawing->getShadow()->getAlpha() * 1000);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
/*
|
||||
|
||||
// a:scene3d
|
||||
$objWriter->startElement('a:scene3d');
|
||||
|
||||
// a:camera
|
||||
$objWriter->startElement('a:camera');
|
||||
$objWriter->writeAttribute('prst', 'orthographicFront');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:lightRig
|
||||
$objWriter->startElement('a:lightRig');
|
||||
$objWriter->writeAttribute('rig', 'twoPt');
|
||||
$objWriter->writeAttribute('dir', 't');
|
||||
|
||||
// a:rot
|
||||
$objWriter->startElement('a:rot');
|
||||
$objWriter->writeAttribute('lat', '0');
|
||||
$objWriter->writeAttribute('lon', '0');
|
||||
$objWriter->writeAttribute('rev', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
*/
|
||||
/*
|
||||
// a:sp3d
|
||||
$objWriter->startElement('a:sp3d');
|
||||
|
||||
// a:bevelT
|
||||
$objWriter->startElement('a:bevelT');
|
||||
$objWriter->writeAttribute('w', '25400');
|
||||
$objWriter->writeAttribute('h', '19050');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:contourClr
|
||||
$objWriter->startElement('a:contourClr');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', 'FFFFFF');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
*/
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// xdr:clientData
|
||||
$objWriter->writeElement('xdr:clientData', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write VML header/footer images to XML format
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pWorksheet
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeVMLHeaderFooterImages(PHPExcel_Worksheet $pWorksheet = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Header/footer images
|
||||
$images = $pWorksheet->getHeaderFooter()->getImages();
|
||||
|
||||
// xml
|
||||
$objWriter->startElement('xml');
|
||||
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
|
||||
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
|
||||
$objWriter->writeAttribute('xmlns:x', 'urn:schemas-microsoft-com:office:excel');
|
||||
|
||||
// o:shapelayout
|
||||
$objWriter->startElement('o:shapelayout');
|
||||
$objWriter->writeAttribute('v:ext', 'edit');
|
||||
|
||||
// o:idmap
|
||||
$objWriter->startElement('o:idmap');
|
||||
$objWriter->writeAttribute('v:ext', 'edit');
|
||||
$objWriter->writeAttribute('data', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:shapetype
|
||||
$objWriter->startElement('v:shapetype');
|
||||
$objWriter->writeAttribute('id', '_x0000_t75');
|
||||
$objWriter->writeAttribute('coordsize', '21600,21600');
|
||||
$objWriter->writeAttribute('o:spt', '75');
|
||||
$objWriter->writeAttribute('o:preferrelative', 't');
|
||||
$objWriter->writeAttribute('path', 'm@4@5l@4@11@9@11@9@5xe');
|
||||
$objWriter->writeAttribute('filled', 'f');
|
||||
$objWriter->writeAttribute('stroked', 'f');
|
||||
|
||||
// v:stroke
|
||||
$objWriter->startElement('v:stroke');
|
||||
$objWriter->writeAttribute('joinstyle', 'miter');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:formulas
|
||||
$objWriter->startElement('v:formulas');
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'if lineDrawn pixelLineWidth 0');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'sum @0 1 0');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'sum 0 0 @1');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'prod @2 1 2');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'prod @3 21600 pixelWidth');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'prod @3 21600 pixelHeight');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'sum @0 0 1');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'prod @6 1 2');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'prod @7 21600 pixelWidth');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'sum @8 21600 0');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'prod @7 21600 pixelHeight');
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:f
|
||||
$objWriter->startElement('v:f');
|
||||
$objWriter->writeAttribute('eqn', 'sum @10 21600 0');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// v:path
|
||||
$objWriter->startElement('v:path');
|
||||
$objWriter->writeAttribute('o:extrusionok', 'f');
|
||||
$objWriter->writeAttribute('gradientshapeok', 't');
|
||||
$objWriter->writeAttribute('o:connecttype', 'rect');
|
||||
$objWriter->endElement();
|
||||
|
||||
// o:lock
|
||||
$objWriter->startElement('o:lock');
|
||||
$objWriter->writeAttribute('v:ext', 'edit');
|
||||
$objWriter->writeAttribute('aspectratio', 't');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Loop through images
|
||||
foreach ($images as $key => $value) {
|
||||
$this->_writeVMLHeaderFooterImage($objWriter, $key, $value);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write VML comment to XML format
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pReference Reference
|
||||
* @param PHPExcel_Worksheet_HeaderFooterDrawing $pImage Image
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function _writeVMLHeaderFooterImage(PHPExcel_Shared_XMLWriter $objWriter = null, $pReference = '', PHPExcel_Worksheet_HeaderFooterDrawing $pImage = null)
|
||||
{
|
||||
// Calculate object id
|
||||
preg_match('{(\d+)}', md5($pReference), $m);
|
||||
$id = 1500 + (substr($m[1], 0, 2) * 1);
|
||||
|
||||
// Calculate offset
|
||||
$width = $pImage->getWidth();
|
||||
$height = $pImage->getHeight();
|
||||
$marginLeft = $pImage->getOffsetX();
|
||||
$marginTop = $pImage->getOffsetY();
|
||||
|
||||
// v:shape
|
||||
$objWriter->startElement('v:shape');
|
||||
$objWriter->writeAttribute('id', $pReference);
|
||||
$objWriter->writeAttribute('o:spid', '_x0000_s' . $id);
|
||||
$objWriter->writeAttribute('type', '#_x0000_t75');
|
||||
$objWriter->writeAttribute('style', "position:absolute;margin-left:{$marginLeft}px;margin-top:{$marginTop}px;width:{$width}px;height:{$height}px;z-index:1");
|
||||
|
||||
// v:imagedata
|
||||
$objWriter->startElement('v:imagedata');
|
||||
$objWriter->writeAttribute('o:relid', 'rId' . $pReference);
|
||||
$objWriter->writeAttribute('o:title', $pImage->getName());
|
||||
$objWriter->endElement();
|
||||
|
||||
// o:lock
|
||||
$objWriter->startElement('o:lock');
|
||||
$objWriter->writeAttribute('v:ext', 'edit');
|
||||
$objWriter->writeAttribute('rotation', 't');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an array of all drawings
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return PHPExcel_Worksheet_Drawing[] All drawings in PHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function allDrawings(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Get an array of all drawings
|
||||
$aDrawings = array();
|
||||
|
||||
// Loop through PHPExcel
|
||||
$sheetCount = $pPHPExcel->getSheetCount();
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
// Loop through images and add to array
|
||||
$iterator = $pPHPExcel->getSheet($i)->getDrawingCollection()->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
$aDrawings[] = $iterator->current();
|
||||
|
||||
$iterator->next();
|
||||
}
|
||||
}
|
||||
|
||||
return $aDrawings;
|
||||
}
|
||||
}
|
437
extend/phpexcel/PHPExcel/Writer/Excel2007/Rels.php
Executable file
437
extend/phpexcel/PHPExcel/Writer/Excel2007/Rels.php
Executable file
@ -0,0 +1,437 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_Rels
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write relationships to XML format
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeRelationships(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
|
||||
if (!empty($customPropertyList)) {
|
||||
// Relationship docProps/app.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
4,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties',
|
||||
'docProps/custom.xml'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Relationship docProps/app.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
3,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties',
|
||||
'docProps/app.xml'
|
||||
);
|
||||
|
||||
// Relationship docProps/core.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
2,
|
||||
'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties',
|
||||
'docProps/core.xml'
|
||||
);
|
||||
|
||||
// Relationship xl/workbook.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument',
|
||||
'xl/workbook.xml'
|
||||
);
|
||||
// a custom UI in workbook ?
|
||||
if($pPHPExcel->hasRibbon()){
|
||||
$this->_writeRelationShip(
|
||||
$objWriter,
|
||||
5,
|
||||
'http://schemas.microsoft.com/office/2006/relationships/ui/extensibility',
|
||||
$pPHPExcel->getRibbonXMLData('target')
|
||||
);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write workbook relationships to XML format
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeWorkbookRelationships(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationship styles.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
||||
'styles.xml'
|
||||
);
|
||||
|
||||
// Relationship theme/theme1.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
2,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||
'theme/theme1.xml'
|
||||
);
|
||||
|
||||
// Relationship sharedStrings.xml
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
3,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings',
|
||||
'sharedStrings.xml'
|
||||
);
|
||||
|
||||
// Relationships with sheets
|
||||
$sheetCount = $pPHPExcel->getSheetCount();
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
($i + 1 + 3),
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet',
|
||||
'worksheets/sheet' . ($i + 1) . '.xml'
|
||||
);
|
||||
}
|
||||
// Relationships for vbaProject if needed
|
||||
// id : just after the last sheet
|
||||
if($pPHPExcel->hasMacros()){
|
||||
$this->_writeRelationShip(
|
||||
$objWriter,
|
||||
($i + 1 + 3),
|
||||
'http://schemas.microsoft.com/office/2006/relationships/vbaProject',
|
||||
'vbaProject.bin'
|
||||
);
|
||||
++$i;//increment i if needed for an another relation
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write worksheet relationships to XML format
|
||||
*
|
||||
* Numbering is as follows:
|
||||
* rId1 - Drawings
|
||||
* rId_hyperlink_x - Hyperlinks
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pWorksheet
|
||||
* @param int $pWorksheetId
|
||||
* @param boolean $includeCharts Flag indicating if we should write charts
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeWorksheetRelationships(PHPExcel_Worksheet $pWorksheet = null, $pWorksheetId = 1, $includeCharts = FALSE)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Write drawing relationships?
|
||||
$d = 0;
|
||||
if ($includeCharts) {
|
||||
$charts = $pWorksheet->getChartCollection();
|
||||
} else {
|
||||
$charts = array();
|
||||
}
|
||||
if (($pWorksheet->getDrawingCollection()->count() > 0) ||
|
||||
(count($charts) > 0)) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
++$d,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing',
|
||||
'../drawings/drawing' . $pWorksheetId . '.xml'
|
||||
);
|
||||
}
|
||||
|
||||
// Write chart relationships?
|
||||
// $chartCount = 0;
|
||||
// $charts = $pWorksheet->getChartCollection();
|
||||
// echo 'Chart Rels: ' , count($charts) , '<br />';
|
||||
// if (count($charts) > 0) {
|
||||
// foreach($charts as $chart) {
|
||||
// $this->_writeRelationship(
|
||||
// $objWriter,
|
||||
// ++$d,
|
||||
// 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
|
||||
// '../charts/chart' . ++$chartCount . '.xml'
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Write hyperlink relationships?
|
||||
$i = 1;
|
||||
foreach ($pWorksheet->getHyperlinkCollection() as $hyperlink) {
|
||||
if (!$hyperlink->isInternal()) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
'_hyperlink_' . $i,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink',
|
||||
$hyperlink->getUrl(),
|
||||
'External'
|
||||
);
|
||||
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
|
||||
// Write comments relationship?
|
||||
$i = 1;
|
||||
if (count($pWorksheet->getComments()) > 0) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
'_comments_vml' . $i,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
|
||||
'../drawings/vmlDrawing' . $pWorksheetId . '.vml'
|
||||
);
|
||||
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
'_comments' . $i,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments',
|
||||
'../comments' . $pWorksheetId . '.xml'
|
||||
);
|
||||
}
|
||||
|
||||
// Write header/footer relationship?
|
||||
$i = 1;
|
||||
if (count($pWorksheet->getHeaderFooter()->getImages()) > 0) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
'_headerfooter_vml' . $i,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing',
|
||||
'../drawings/vmlDrawingHF' . $pWorksheetId . '.vml'
|
||||
);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write drawing relationships to XML format
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pWorksheet
|
||||
* @param int &$chartRef Chart ID
|
||||
* @param boolean $includeCharts Flag indicating if we should write charts
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null, &$chartRef, $includeCharts = FALSE)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Loop through images and write relationships
|
||||
$i = 1;
|
||||
$iterator = $pWorksheet->getDrawingCollection()->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
if ($iterator->current() instanceof PHPExcel_Worksheet_Drawing
|
||||
|| $iterator->current() instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
||||
// Write relationship for image drawing
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$i,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
|
||||
'../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename())
|
||||
);
|
||||
}
|
||||
|
||||
$iterator->next();
|
||||
++$i;
|
||||
}
|
||||
|
||||
if ($includeCharts) {
|
||||
// Loop through charts and write relationships
|
||||
$chartCount = $pWorksheet->getChartCount();
|
||||
if ($chartCount > 0) {
|
||||
for ($c = 0; $c < $chartCount; ++$c) {
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$i++,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart',
|
||||
'../charts/chart' . ++$chartRef . '.xml'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write header/footer drawing relationships to XML format
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pWorksheet
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeHeaderFooterDrawingRelationships(PHPExcel_Worksheet $pWorksheet = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Loop through images and write relationships
|
||||
foreach ($pWorksheet->getHeaderFooter()->getImages() as $key => $value) {
|
||||
// Write relationship for image drawing
|
||||
$this->_writeRelationship(
|
||||
$objWriter,
|
||||
$key,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image',
|
||||
'../media/' . $value->getIndexedFilename()
|
||||
);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Override content type
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param int $pId Relationship ID. rId will be prepended!
|
||||
* @param string $pType Relationship type
|
||||
* @param string $pTarget Relationship target
|
||||
* @param string $pTargetMode Relationship target mode
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeRelationship(PHPExcel_Shared_XMLWriter $objWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '')
|
||||
{
|
||||
if ($pType != '' && $pTarget != '') {
|
||||
// Write relationship
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', 'rId' . $pId);
|
||||
$objWriter->writeAttribute('Type', $pType);
|
||||
$objWriter->writeAttribute('Target', $pTarget);
|
||||
|
||||
if ($pTargetMode != '') {
|
||||
$objWriter->writeAttribute('TargetMode', $pTargetMode);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
}
|
77
extend/phpexcel/PHPExcel/Writer/Excel2007/RelsRibbon.php
Executable file
77
extend/phpexcel/PHPExcel/Writer/Excel2007/RelsRibbon.php
Executable file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_RelsRibbon
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write relationships for additional objects of custom UI (ribbon)
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeRibbonRelationships(PHPExcel $pPHPExcel = null){
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
$localRels=$pPHPExcel->getRibbonBinObjects('names');
|
||||
if(is_array($localRels)){
|
||||
foreach($localRels as $aId=>$aTarget){
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', $aId);
|
||||
$objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image');
|
||||
$objWriter->writeAttribute('Target', $aTarget);
|
||||
$objWriter->endElement();//Relationship
|
||||
}
|
||||
}
|
||||
$objWriter->endElement();//Relationships
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
|
||||
}
|
||||
|
||||
}
|
72
extend/phpexcel/PHPExcel/Writer/Excel2007/RelsVBA.php
Executable file
72
extend/phpexcel/PHPExcel/Writer/Excel2007/RelsVBA.php
Executable file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_RelsVBA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_RelsVBA extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write relationships for a signed VBA Project
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeVBARelationships(PHPExcel $pPHPExcel = null){
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// Relationships
|
||||
$objWriter->startElement('Relationships');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
$objWriter->startElement('Relationship');
|
||||
$objWriter->writeAttribute('Id', 'rId1');
|
||||
$objWriter->writeAttribute('Type', 'http://schemas.microsoft.com/office/2006/relationships/vbaProjectSignature');
|
||||
$objWriter->writeAttribute('Target', 'vbaProjectSignature.bin');
|
||||
$objWriter->endElement();//Relationship
|
||||
$objWriter->endElement();//Relationships
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
|
||||
}
|
||||
|
||||
}
|
319
extend/phpexcel/PHPExcel/Writer/Excel2007/StringTable.php
Executable file
319
extend/phpexcel/PHPExcel/Writer/Excel2007/StringTable.php
Executable file
@ -0,0 +1,319 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_StringTable
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Create worksheet stringtable
|
||||
*
|
||||
* @param PHPExcel_Worksheet $pSheet Worksheet
|
||||
* @param string[] $pExistingTable Existing table to eventually merge with
|
||||
* @return string[] String table for worksheet
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function createStringTable($pSheet = null, $pExistingTable = null)
|
||||
{
|
||||
if ($pSheet !== NULL) {
|
||||
// Create string lookup table
|
||||
$aStringTable = array();
|
||||
$cellCollection = null;
|
||||
$aFlippedStringTable = null; // For faster lookup
|
||||
|
||||
// Is an existing table given?
|
||||
if (($pExistingTable !== NULL) && is_array($pExistingTable)) {
|
||||
$aStringTable = $pExistingTable;
|
||||
}
|
||||
|
||||
// Fill index array
|
||||
$aFlippedStringTable = $this->flipStringTable($aStringTable);
|
||||
|
||||
// Loop through cells
|
||||
foreach ($pSheet->getCellCollection() as $cellID) {
|
||||
$cell = $pSheet->getCell($cellID);
|
||||
$cellValue = $cell->getValue();
|
||||
if (!is_object($cellValue) &&
|
||||
($cellValue !== NULL) &&
|
||||
$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)) {
|
||||
$aStringTable[] = $cellValue;
|
||||
$aFlippedStringTable[$cellValue] = true;
|
||||
} elseif ($cellValue instanceof PHPExcel_RichText &&
|
||||
($cellValue !== NULL) &&
|
||||
!isset($aFlippedStringTable[$cellValue->getHashCode()])) {
|
||||
$aStringTable[] = $cellValue;
|
||||
$aFlippedStringTable[$cellValue->getHashCode()] = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
return $aStringTable;
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("Invalid PHPExcel_Worksheet object passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write string table to XML format
|
||||
*
|
||||
* @param string[] $pStringTable
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeStringTable($pStringTable = null)
|
||||
{
|
||||
if ($pStringTable !== NULL) {
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// String table
|
||||
$objWriter->startElement('sst');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
||||
$objWriter->writeAttribute('uniqueCount', count($pStringTable));
|
||||
|
||||
// Loop through string table
|
||||
foreach ($pStringTable as $textElement) {
|
||||
$objWriter->startElement('si');
|
||||
|
||||
if (! $textElement instanceof PHPExcel_RichText) {
|
||||
$textToWrite = PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $textElement );
|
||||
$objWriter->startElement('t');
|
||||
if ($textToWrite !== trim($textToWrite)) {
|
||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||
}
|
||||
$objWriter->writeRawData($textToWrite);
|
||||
$objWriter->endElement();
|
||||
} else if ($textElement instanceof PHPExcel_RichText) {
|
||||
$this->writeRichText($objWriter, $textElement);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("Invalid string table array passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Rich Text
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_RichText $pRichText Rich text
|
||||
* @param string $prefix Optional Namespace prefix
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeRichText(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_RichText $pRichText = null, $prefix=NULL)
|
||||
{
|
||||
if ($prefix !== NULL)
|
||||
$prefix .= ':';
|
||||
// Loop through rich text elements
|
||||
$elements = $pRichText->getRichTextElements();
|
||||
foreach ($elements as $element) {
|
||||
// r
|
||||
$objWriter->startElement($prefix.'r');
|
||||
|
||||
// rPr
|
||||
if ($element instanceof PHPExcel_RichText_Run) {
|
||||
// rPr
|
||||
$objWriter->startElement($prefix.'rPr');
|
||||
|
||||
// rFont
|
||||
$objWriter->startElement($prefix.'rFont');
|
||||
$objWriter->writeAttribute('val', $element->getFont()->getName());
|
||||
$objWriter->endElement();
|
||||
|
||||
// Bold
|
||||
$objWriter->startElement($prefix.'b');
|
||||
$objWriter->writeAttribute('val', ($element->getFont()->getBold() ? 'true' : 'false'));
|
||||
$objWriter->endElement();
|
||||
|
||||
// Italic
|
||||
$objWriter->startElement($prefix.'i');
|
||||
$objWriter->writeAttribute('val', ($element->getFont()->getItalic() ? 'true' : 'false'));
|
||||
$objWriter->endElement();
|
||||
|
||||
// Superscript / subscript
|
||||
if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
|
||||
$objWriter->startElement($prefix.'vertAlign');
|
||||
if ($element->getFont()->getSuperScript()) {
|
||||
$objWriter->writeAttribute('val', 'superscript');
|
||||
} else if ($element->getFont()->getSubScript()) {
|
||||
$objWriter->writeAttribute('val', 'subscript');
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Strikethrough
|
||||
$objWriter->startElement($prefix.'strike');
|
||||
$objWriter->writeAttribute('val', ($element->getFont()->getStrikethrough() ? 'true' : 'false'));
|
||||
$objWriter->endElement();
|
||||
|
||||
// Color
|
||||
$objWriter->startElement($prefix.'color');
|
||||
$objWriter->writeAttribute('rgb', $element->getFont()->getColor()->getARGB());
|
||||
$objWriter->endElement();
|
||||
|
||||
// Size
|
||||
$objWriter->startElement($prefix.'sz');
|
||||
$objWriter->writeAttribute('val', $element->getFont()->getSize());
|
||||
$objWriter->endElement();
|
||||
|
||||
// Underline
|
||||
$objWriter->startElement($prefix.'u');
|
||||
$objWriter->writeAttribute('val', $element->getFont()->getUnderline());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// t
|
||||
$objWriter->startElement($prefix.'t');
|
||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Rich Text
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string|PHPExcel_RichText $pRichText text string or Rich text
|
||||
* @param string $prefix Optional Namespace prefix
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeRichTextForCharts(PHPExcel_Shared_XMLWriter $objWriter = null, $pRichText = null, $prefix=NULL)
|
||||
{
|
||||
if (!$pRichText instanceof PHPExcel_RichText) {
|
||||
$textRun = $pRichText;
|
||||
$pRichText = new PHPExcel_RichText();
|
||||
$pRichText->createTextRun($textRun);
|
||||
}
|
||||
|
||||
if ($prefix !== NULL)
|
||||
$prefix .= ':';
|
||||
// Loop through rich text elements
|
||||
$elements = $pRichText->getRichTextElements();
|
||||
foreach ($elements as $element) {
|
||||
// r
|
||||
$objWriter->startElement($prefix.'r');
|
||||
|
||||
// rPr
|
||||
$objWriter->startElement($prefix.'rPr');
|
||||
|
||||
// Bold
|
||||
$objWriter->writeAttribute('b', ($element->getFont()->getBold() ? 1 : 0));
|
||||
// Italic
|
||||
$objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 1 : 0));
|
||||
// Underline
|
||||
$underlineType = $element->getFont()->getUnderline();
|
||||
switch($underlineType) {
|
||||
case 'single' :
|
||||
$underlineType = 'sng';
|
||||
break;
|
||||
case 'double' :
|
||||
$underlineType = 'dbl';
|
||||
break;
|
||||
}
|
||||
$objWriter->writeAttribute('u', $underlineType);
|
||||
// Strikethrough
|
||||
$objWriter->writeAttribute('strike', ($element->getFont()->getStrikethrough() ? 'sngStrike' : 'noStrike'));
|
||||
|
||||
// rFont
|
||||
$objWriter->startElement($prefix.'latin');
|
||||
$objWriter->writeAttribute('typeface', $element->getFont()->getName());
|
||||
$objWriter->endElement();
|
||||
|
||||
// Superscript / subscript
|
||||
// if ($element->getFont()->getSuperScript() || $element->getFont()->getSubScript()) {
|
||||
// $objWriter->startElement($prefix.'vertAlign');
|
||||
// if ($element->getFont()->getSuperScript()) {
|
||||
// $objWriter->writeAttribute('val', 'superscript');
|
||||
// } else if ($element->getFont()->getSubScript()) {
|
||||
// $objWriter->writeAttribute('val', 'subscript');
|
||||
// }
|
||||
// $objWriter->endElement();
|
||||
// }
|
||||
//
|
||||
$objWriter->endElement();
|
||||
|
||||
// t
|
||||
$objWriter->startElement($prefix.'t');
|
||||
// $objWriter->writeAttribute('xml:space', 'preserve'); // Excel2010 accepts, Excel2007 complains
|
||||
$objWriter->writeRawData(PHPExcel_Shared_String::ControlCharacterPHP2OOXML( $element->getText() ));
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flip string table (for index searching)
|
||||
*
|
||||
* @param array $stringTable Stringtable
|
||||
* @return array
|
||||
*/
|
||||
public function flipStringTable($stringTable = array()) {
|
||||
// Return value
|
||||
$returnValue = array();
|
||||
|
||||
// Loop through stringtable and add flipped items to $returnValue
|
||||
foreach ($stringTable as $key => $value) {
|
||||
if (! $value instanceof PHPExcel_RichText) {
|
||||
$returnValue[$value] = $key;
|
||||
} else if ($value instanceof PHPExcel_RichText) {
|
||||
$returnValue[$value->getHashCode()] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
// Return
|
||||
return $returnValue;
|
||||
}
|
||||
}
|
704
extend/phpexcel/PHPExcel/Writer/Excel2007/Style.php
Executable file
704
extend/phpexcel/PHPExcel/Writer/Excel2007/Style.php
Executable file
@ -0,0 +1,704 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_Style
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write styles to XML format
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeStyles(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// styleSheet
|
||||
$objWriter->startElement('styleSheet');
|
||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
||||
|
||||
// numFmts
|
||||
$objWriter->startElement('numFmts');
|
||||
$objWriter->writeAttribute('count', $this->getParentWriter()->getNumFmtHashTable()->count());
|
||||
|
||||
// numFmt
|
||||
for ($i = 0; $i < $this->getParentWriter()->getNumFmtHashTable()->count(); ++$i) {
|
||||
$this->_writeNumFmt($objWriter, $this->getParentWriter()->getNumFmtHashTable()->getByIndex($i), $i);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// fonts
|
||||
$objWriter->startElement('fonts');
|
||||
$objWriter->writeAttribute('count', $this->getParentWriter()->getFontHashTable()->count());
|
||||
|
||||
// font
|
||||
for ($i = 0; $i < $this->getParentWriter()->getFontHashTable()->count(); ++$i) {
|
||||
$this->_writeFont($objWriter, $this->getParentWriter()->getFontHashTable()->getByIndex($i));
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// fills
|
||||
$objWriter->startElement('fills');
|
||||
$objWriter->writeAttribute('count', $this->getParentWriter()->getFillHashTable()->count());
|
||||
|
||||
// fill
|
||||
for ($i = 0; $i < $this->getParentWriter()->getFillHashTable()->count(); ++$i) {
|
||||
$this->_writeFill($objWriter, $this->getParentWriter()->getFillHashTable()->getByIndex($i));
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// borders
|
||||
$objWriter->startElement('borders');
|
||||
$objWriter->writeAttribute('count', $this->getParentWriter()->getBordersHashTable()->count());
|
||||
|
||||
// border
|
||||
for ($i = 0; $i < $this->getParentWriter()->getBordersHashTable()->count(); ++$i) {
|
||||
$this->_writeBorder($objWriter, $this->getParentWriter()->getBordersHashTable()->getByIndex($i));
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// cellStyleXfs
|
||||
$objWriter->startElement('cellStyleXfs');
|
||||
$objWriter->writeAttribute('count', 1);
|
||||
|
||||
// xf
|
||||
$objWriter->startElement('xf');
|
||||
$objWriter->writeAttribute('numFmtId', 0);
|
||||
$objWriter->writeAttribute('fontId', 0);
|
||||
$objWriter->writeAttribute('fillId', 0);
|
||||
$objWriter->writeAttribute('borderId', 0);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// cellXfs
|
||||
$objWriter->startElement('cellXfs');
|
||||
$objWriter->writeAttribute('count', count($pPHPExcel->getCellXfCollection()));
|
||||
|
||||
// xf
|
||||
foreach ($pPHPExcel->getCellXfCollection() as $cellXf) {
|
||||
$this->_writeCellStyleXf($objWriter, $cellXf, $pPHPExcel);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// cellStyles
|
||||
$objWriter->startElement('cellStyles');
|
||||
$objWriter->writeAttribute('count', 1);
|
||||
|
||||
// cellStyle
|
||||
$objWriter->startElement('cellStyle');
|
||||
$objWriter->writeAttribute('name', 'Normal');
|
||||
$objWriter->writeAttribute('xfId', 0);
|
||||
$objWriter->writeAttribute('builtinId', 0);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// dxfs
|
||||
$objWriter->startElement('dxfs');
|
||||
$objWriter->writeAttribute('count', $this->getParentWriter()->getStylesConditionalHashTable()->count());
|
||||
|
||||
// dxf
|
||||
for ($i = 0; $i < $this->getParentWriter()->getStylesConditionalHashTable()->count(); ++$i) {
|
||||
$this->_writeCellStyleDxf($objWriter, $this->getParentWriter()->getStylesConditionalHashTable()->getByIndex($i)->getStyle());
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// tableStyles
|
||||
$objWriter->startElement('tableStyles');
|
||||
$objWriter->writeAttribute('defaultTableStyle', 'TableStyleMedium9');
|
||||
$objWriter->writeAttribute('defaultPivotStyle', 'PivotTableStyle1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Fill
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Style_Fill $pFill Fill style
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeFill(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Fill $pFill = null)
|
||||
{
|
||||
// Check if this is a pattern type or gradient type
|
||||
if ($pFill->getFillType() === PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR ||
|
||||
$pFill->getFillType() === PHPExcel_Style_Fill::FILL_GRADIENT_PATH) {
|
||||
// Gradient fill
|
||||
$this->_writeGradientFill($objWriter, $pFill);
|
||||
} elseif($pFill->getFillType() !== NULL) {
|
||||
// Pattern fill
|
||||
$this->_writePatternFill($objWriter, $pFill);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Gradient Fill
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Style_Fill $pFill Fill style
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeGradientFill(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Fill $pFill = null)
|
||||
{
|
||||
// fill
|
||||
$objWriter->startElement('fill');
|
||||
|
||||
// gradientFill
|
||||
$objWriter->startElement('gradientFill');
|
||||
$objWriter->writeAttribute('type', $pFill->getFillType());
|
||||
$objWriter->writeAttribute('degree', $pFill->getRotation());
|
||||
|
||||
// stop
|
||||
$objWriter->startElement('stop');
|
||||
$objWriter->writeAttribute('position', '0');
|
||||
|
||||
// color
|
||||
$objWriter->startElement('color');
|
||||
$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// stop
|
||||
$objWriter->startElement('stop');
|
||||
$objWriter->writeAttribute('position', '1');
|
||||
|
||||
// color
|
||||
$objWriter->startElement('color');
|
||||
$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Pattern Fill
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Style_Fill $pFill Fill style
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writePatternFill(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Fill $pFill = null)
|
||||
{
|
||||
// fill
|
||||
$objWriter->startElement('fill');
|
||||
|
||||
// patternFill
|
||||
$objWriter->startElement('patternFill');
|
||||
$objWriter->writeAttribute('patternType', $pFill->getFillType());
|
||||
|
||||
if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) {
|
||||
// fgColor
|
||||
if ($pFill->getStartColor()->getARGB()) {
|
||||
$objWriter->startElement('fgColor');
|
||||
$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) {
|
||||
// bgColor
|
||||
if ($pFill->getEndColor()->getARGB()) {
|
||||
$objWriter->startElement('bgColor');
|
||||
$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Font
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Style_Font $pFont Font style
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeFont(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Font $pFont = null)
|
||||
{
|
||||
// font
|
||||
$objWriter->startElement('font');
|
||||
// Weird! The order of these elements actually makes a difference when opening Excel2007
|
||||
// files in Excel2003 with the compatibility pack. It's not documented behaviour,
|
||||
// and makes for a real WTF!
|
||||
|
||||
// Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
|
||||
// for conditional formatting). Otherwise it will apparently not be picked up in conditional
|
||||
// formatting style dialog
|
||||
if ($pFont->getBold() !== NULL) {
|
||||
$objWriter->startElement('b');
|
||||
$objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Italic
|
||||
if ($pFont->getItalic() !== NULL) {
|
||||
$objWriter->startElement('i');
|
||||
$objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Strikethrough
|
||||
if ($pFont->getStrikethrough() !== NULL) {
|
||||
$objWriter->startElement('strike');
|
||||
$objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Underline
|
||||
if ($pFont->getUnderline() !== NULL) {
|
||||
$objWriter->startElement('u');
|
||||
$objWriter->writeAttribute('val', $pFont->getUnderline());
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Superscript / subscript
|
||||
if ($pFont->getSuperScript() === TRUE || $pFont->getSubScript() === TRUE) {
|
||||
$objWriter->startElement('vertAlign');
|
||||
if ($pFont->getSuperScript() === TRUE) {
|
||||
$objWriter->writeAttribute('val', 'superscript');
|
||||
} else if ($pFont->getSubScript() === TRUE) {
|
||||
$objWriter->writeAttribute('val', 'subscript');
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Size
|
||||
if ($pFont->getSize() !== NULL) {
|
||||
$objWriter->startElement('sz');
|
||||
$objWriter->writeAttribute('val', $pFont->getSize());
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Foreground color
|
||||
if ($pFont->getColor()->getARGB() !== NULL) {
|
||||
$objWriter->startElement('color');
|
||||
$objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
// Name
|
||||
if ($pFont->getName() !== NULL) {
|
||||
$objWriter->startElement('name');
|
||||
$objWriter->writeAttribute('val', $pFont->getName());
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Border
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Style_Borders $pBorders Borders style
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeBorder(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_Borders $pBorders = null)
|
||||
{
|
||||
// Write border
|
||||
$objWriter->startElement('border');
|
||||
// Diagonal?
|
||||
switch ($pBorders->getDiagonalDirection()) {
|
||||
case PHPExcel_Style_Borders::DIAGONAL_UP:
|
||||
$objWriter->writeAttribute('diagonalUp', 'true');
|
||||
$objWriter->writeAttribute('diagonalDown', 'false');
|
||||
break;
|
||||
case PHPExcel_Style_Borders::DIAGONAL_DOWN:
|
||||
$objWriter->writeAttribute('diagonalUp', 'false');
|
||||
$objWriter->writeAttribute('diagonalDown', 'true');
|
||||
break;
|
||||
case PHPExcel_Style_Borders::DIAGONAL_BOTH:
|
||||
$objWriter->writeAttribute('diagonalUp', 'true');
|
||||
$objWriter->writeAttribute('diagonalDown', 'true');
|
||||
break;
|
||||
}
|
||||
|
||||
// BorderPr
|
||||
$this->_writeBorderPr($objWriter, 'left', $pBorders->getLeft());
|
||||
$this->_writeBorderPr($objWriter, 'right', $pBorders->getRight());
|
||||
$this->_writeBorderPr($objWriter, 'top', $pBorders->getTop());
|
||||
$this->_writeBorderPr($objWriter, 'bottom', $pBorders->getBottom());
|
||||
$this->_writeBorderPr($objWriter, 'diagonal', $pBorders->getDiagonal());
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Cell Style Xf
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Style $pStyle Style
|
||||
* @param PHPExcel $pPHPExcel Workbook
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeCellStyleXf(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style $pStyle = null, PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// xf
|
||||
$objWriter->startElement('xf');
|
||||
$objWriter->writeAttribute('xfId', 0);
|
||||
$objWriter->writeAttribute('fontId', (int)$this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode()));
|
||||
if ($pStyle->getQuotePrefix()) {
|
||||
$objWriter->writeAttribute('quotePrefix', 1);
|
||||
}
|
||||
|
||||
if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) {
|
||||
$objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164) );
|
||||
} else {
|
||||
$objWriter->writeAttribute('numFmtId', (int)$pStyle->getNumberFormat()->getBuiltInFormatCode());
|
||||
}
|
||||
|
||||
$objWriter->writeAttribute('fillId', (int)$this->getParentWriter()->getFillHashTable()->getIndexForHashCode($pStyle->getFill()->getHashCode()));
|
||||
$objWriter->writeAttribute('borderId', (int)$this->getParentWriter()->getBordersHashTable()->getIndexForHashCode($pStyle->getBorders()->getHashCode()));
|
||||
|
||||
// Apply styles?
|
||||
$objWriter->writeAttribute('applyFont', ($pPHPExcel->getDefaultStyle()->getFont()->getHashCode() != $pStyle->getFont()->getHashCode()) ? '1' : '0');
|
||||
$objWriter->writeAttribute('applyNumberFormat', ($pPHPExcel->getDefaultStyle()->getNumberFormat()->getHashCode() != $pStyle->getNumberFormat()->getHashCode()) ? '1' : '0');
|
||||
$objWriter->writeAttribute('applyFill', ($pPHPExcel->getDefaultStyle()->getFill()->getHashCode() != $pStyle->getFill()->getHashCode()) ? '1' : '0');
|
||||
$objWriter->writeAttribute('applyBorder', ($pPHPExcel->getDefaultStyle()->getBorders()->getHashCode() != $pStyle->getBorders()->getHashCode()) ? '1' : '0');
|
||||
$objWriter->writeAttribute('applyAlignment', ($pPHPExcel->getDefaultStyle()->getAlignment()->getHashCode() != $pStyle->getAlignment()->getHashCode()) ? '1' : '0');
|
||||
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
|
||||
$objWriter->writeAttribute('applyProtection', 'true');
|
||||
}
|
||||
|
||||
// alignment
|
||||
$objWriter->startElement('alignment');
|
||||
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
|
||||
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
|
||||
|
||||
$textRotation = 0;
|
||||
if ($pStyle->getAlignment()->getTextRotation() >= 0) {
|
||||
$textRotation = $pStyle->getAlignment()->getTextRotation();
|
||||
} else if ($pStyle->getAlignment()->getTextRotation() < 0) {
|
||||
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
|
||||
}
|
||||
$objWriter->writeAttribute('textRotation', $textRotation);
|
||||
|
||||
$objWriter->writeAttribute('wrapText', ($pStyle->getAlignment()->getWrapText() ? 'true' : 'false'));
|
||||
$objWriter->writeAttribute('shrinkToFit', ($pStyle->getAlignment()->getShrinkToFit() ? 'true' : 'false'));
|
||||
|
||||
if ($pStyle->getAlignment()->getIndent() > 0) {
|
||||
$objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent());
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// protection
|
||||
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
|
||||
$objWriter->startElement('protection');
|
||||
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
|
||||
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
|
||||
}
|
||||
if ($pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
|
||||
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Cell Style Dxf
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Style $pStyle Style
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeCellStyleDxf(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style $pStyle = null)
|
||||
{
|
||||
// dxf
|
||||
$objWriter->startElement('dxf');
|
||||
|
||||
// font
|
||||
$this->_writeFont($objWriter, $pStyle->getFont());
|
||||
|
||||
// numFmt
|
||||
$this->_writeNumFmt($objWriter, $pStyle->getNumberFormat());
|
||||
|
||||
// fill
|
||||
$this->_writeFill($objWriter, $pStyle->getFill());
|
||||
|
||||
// alignment
|
||||
$objWriter->startElement('alignment');
|
||||
if ($pStyle->getAlignment()->getHorizontal() !== NULL) {
|
||||
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
|
||||
}
|
||||
if ($pStyle->getAlignment()->getVertical() !== NULL) {
|
||||
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
|
||||
}
|
||||
|
||||
if ($pStyle->getAlignment()->getTextRotation() !== NULL) {
|
||||
$textRotation = 0;
|
||||
if ($pStyle->getAlignment()->getTextRotation() >= 0) {
|
||||
$textRotation = $pStyle->getAlignment()->getTextRotation();
|
||||
} else if ($pStyle->getAlignment()->getTextRotation() < 0) {
|
||||
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
|
||||
}
|
||||
$objWriter->writeAttribute('textRotation', $textRotation);
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// border
|
||||
$this->_writeBorder($objWriter, $pStyle->getBorders());
|
||||
|
||||
// protection
|
||||
if (($pStyle->getProtection()->getLocked() !== NULL) ||
|
||||
($pStyle->getProtection()->getHidden() !== NULL)) {
|
||||
if ($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT ||
|
||||
$pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT) {
|
||||
$objWriter->startElement('protection');
|
||||
if (($pStyle->getProtection()->getLocked() !== NULL) &&
|
||||
($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
|
||||
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
|
||||
}
|
||||
if (($pStyle->getProtection()->getHidden() !== NULL) &&
|
||||
($pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
|
||||
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
|
||||
}
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write BorderPr
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pName Element name
|
||||
* @param PHPExcel_Style_Border $pBorder Border style
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeBorderPr(PHPExcel_Shared_XMLWriter $objWriter = null, $pName = 'left', PHPExcel_Style_Border $pBorder = null)
|
||||
{
|
||||
// Write BorderPr
|
||||
if ($pBorder->getBorderStyle() != PHPExcel_Style_Border::BORDER_NONE) {
|
||||
$objWriter->startElement($pName);
|
||||
$objWriter->writeAttribute('style', $pBorder->getBorderStyle());
|
||||
|
||||
// color
|
||||
$objWriter->startElement('color');
|
||||
$objWriter->writeAttribute('rgb', $pBorder->getColor()->getARGB());
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write NumberFormat
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Style_NumberFormat $pNumberFormat Number Format
|
||||
* @param int $pId Number Format identifier
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeNumFmt(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Style_NumberFormat $pNumberFormat = null, $pId = 0)
|
||||
{
|
||||
// Translate formatcode
|
||||
$formatCode = $pNumberFormat->getFormatCode();
|
||||
|
||||
// numFmt
|
||||
if ($formatCode !== NULL) {
|
||||
$objWriter->startElement('numFmt');
|
||||
$objWriter->writeAttribute('numFmtId', ($pId + 164));
|
||||
$objWriter->writeAttribute('formatCode', $formatCode);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all styles
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return PHPExcel_Style[] All styles in PHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function allStyles(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
$aStyles = $pPHPExcel->getCellXfCollection();
|
||||
|
||||
return $aStyles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all conditional styles
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return PHPExcel_Style_Conditional[] All conditional styles in PHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function allConditionalStyles(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Get an array of all styles
|
||||
$aStyles = array();
|
||||
|
||||
$sheetCount = $pPHPExcel->getSheetCount();
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
foreach ($pPHPExcel->getSheet($i)->getConditionalStylesCollection() as $conditionalStyles) {
|
||||
foreach ($conditionalStyles as $conditionalStyle) {
|
||||
$aStyles[] = $conditionalStyle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $aStyles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all fills
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return PHPExcel_Style_Fill[] All fills in PHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function allFills(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Get an array of unique fills
|
||||
$aFills = array();
|
||||
|
||||
// Two first fills are predefined
|
||||
$fill0 = new PHPExcel_Style_Fill();
|
||||
$fill0->setFillType(PHPExcel_Style_Fill::FILL_NONE);
|
||||
$aFills[] = $fill0;
|
||||
|
||||
$fill1 = new PHPExcel_Style_Fill();
|
||||
$fill1->setFillType(PHPExcel_Style_Fill::FILL_PATTERN_GRAY125);
|
||||
$aFills[] = $fill1;
|
||||
// The remaining fills
|
||||
$aStyles = $this->allStyles($pPHPExcel);
|
||||
foreach ($aStyles as $style) {
|
||||
if (!array_key_exists($style->getFill()->getHashCode(), $aFills)) {
|
||||
$aFills[ $style->getFill()->getHashCode() ] = $style->getFill();
|
||||
}
|
||||
}
|
||||
|
||||
return $aFills;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all fonts
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return PHPExcel_Style_Font[] All fonts in PHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function allFonts(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Get an array of unique fonts
|
||||
$aFonts = array();
|
||||
$aStyles = $this->allStyles($pPHPExcel);
|
||||
|
||||
foreach ($aStyles as $style) {
|
||||
if (!array_key_exists($style->getFont()->getHashCode(), $aFonts)) {
|
||||
$aFonts[ $style->getFont()->getHashCode() ] = $style->getFont();
|
||||
}
|
||||
}
|
||||
|
||||
return $aFonts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all borders
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return PHPExcel_Style_Borders[] All borders in PHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function allBorders(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Get an array of unique borders
|
||||
$aBorders = array();
|
||||
$aStyles = $this->allStyles($pPHPExcel);
|
||||
|
||||
foreach ($aStyles as $style) {
|
||||
if (!array_key_exists($style->getBorders()->getHashCode(), $aBorders)) {
|
||||
$aBorders[ $style->getBorders()->getHashCode() ] = $style->getBorders();
|
||||
}
|
||||
}
|
||||
|
||||
return $aBorders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of all number formats
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return PHPExcel_Style_NumberFormat[] All number formats in PHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function allNumberFormats(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Get an array of unique number formats
|
||||
$aNumFmts = array();
|
||||
$aStyles = $this->allStyles($pPHPExcel);
|
||||
|
||||
foreach ($aStyles as $style) {
|
||||
if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !array_key_exists($style->getNumberFormat()->getHashCode(), $aNumFmts)) {
|
||||
$aNumFmts[ $style->getNumberFormat()->getHashCode() ] = $style->getNumberFormat();
|
||||
}
|
||||
}
|
||||
|
||||
return $aNumFmts;
|
||||
}
|
||||
}
|
871
extend/phpexcel/PHPExcel/Writer/Excel2007/Theme.php
Executable file
871
extend/phpexcel/PHPExcel/Writer/Excel2007/Theme.php
Executable file
@ -0,0 +1,871 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_Theme
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Map of Major fonts to write
|
||||
* @static array of string
|
||||
*
|
||||
*/
|
||||
private static $_majorFonts = array(
|
||||
'Jpan' => 'MS Pゴシック',
|
||||
'Hang' => '맑은 고딕',
|
||||
'Hans' => '宋体',
|
||||
'Hant' => '新細明體',
|
||||
'Arab' => 'Times New Roman',
|
||||
'Hebr' => 'Times New Roman',
|
||||
'Thai' => 'Tahoma',
|
||||
'Ethi' => 'Nyala',
|
||||
'Beng' => 'Vrinda',
|
||||
'Gujr' => 'Shruti',
|
||||
'Khmr' => 'MoolBoran',
|
||||
'Knda' => 'Tunga',
|
||||
'Guru' => 'Raavi',
|
||||
'Cans' => 'Euphemia',
|
||||
'Cher' => 'Plantagenet Cherokee',
|
||||
'Yiii' => 'Microsoft Yi Baiti',
|
||||
'Tibt' => 'Microsoft Himalaya',
|
||||
'Thaa' => 'MV Boli',
|
||||
'Deva' => 'Mangal',
|
||||
'Telu' => 'Gautami',
|
||||
'Taml' => 'Latha',
|
||||
'Syrc' => 'Estrangelo Edessa',
|
||||
'Orya' => 'Kalinga',
|
||||
'Mlym' => 'Kartika',
|
||||
'Laoo' => 'DokChampa',
|
||||
'Sinh' => 'Iskoola Pota',
|
||||
'Mong' => 'Mongolian Baiti',
|
||||
'Viet' => 'Times New Roman',
|
||||
'Uigh' => 'Microsoft Uighur',
|
||||
'Geor' => 'Sylfaen',
|
||||
);
|
||||
|
||||
/**
|
||||
* Map of Minor fonts to write
|
||||
* @static array of string
|
||||
*
|
||||
*/
|
||||
private static $_minorFonts = array(
|
||||
'Jpan' => 'MS Pゴシック',
|
||||
'Hang' => '맑은 고딕',
|
||||
'Hans' => '宋体',
|
||||
'Hant' => '新細明體',
|
||||
'Arab' => 'Arial',
|
||||
'Hebr' => 'Arial',
|
||||
'Thai' => 'Tahoma',
|
||||
'Ethi' => 'Nyala',
|
||||
'Beng' => 'Vrinda',
|
||||
'Gujr' => 'Shruti',
|
||||
'Khmr' => 'DaunPenh',
|
||||
'Knda' => 'Tunga',
|
||||
'Guru' => 'Raavi',
|
||||
'Cans' => 'Euphemia',
|
||||
'Cher' => 'Plantagenet Cherokee',
|
||||
'Yiii' => 'Microsoft Yi Baiti',
|
||||
'Tibt' => 'Microsoft Himalaya',
|
||||
'Thaa' => 'MV Boli',
|
||||
'Deva' => 'Mangal',
|
||||
'Telu' => 'Gautami',
|
||||
'Taml' => 'Latha',
|
||||
'Syrc' => 'Estrangelo Edessa',
|
||||
'Orya' => 'Kalinga',
|
||||
'Mlym' => 'Kartika',
|
||||
'Laoo' => 'DokChampa',
|
||||
'Sinh' => 'Iskoola Pota',
|
||||
'Mong' => 'Mongolian Baiti',
|
||||
'Viet' => 'Arial',
|
||||
'Uigh' => 'Microsoft Uighur',
|
||||
'Geor' => 'Sylfaen',
|
||||
);
|
||||
|
||||
/**
|
||||
* Map of core colours
|
||||
* @static array of string
|
||||
*
|
||||
*/
|
||||
private static $_colourScheme = array(
|
||||
'dk2' => '1F497D',
|
||||
'lt2' => 'EEECE1',
|
||||
'accent1' => '4F81BD',
|
||||
'accent2' => 'C0504D',
|
||||
'accent3' => '9BBB59',
|
||||
'accent4' => '8064A2',
|
||||
'accent5' => '4BACC6',
|
||||
'accent6' => 'F79646',
|
||||
'hlink' => '0000FF',
|
||||
'folHlink' => '800080',
|
||||
);
|
||||
|
||||
/**
|
||||
* Write theme to XML format
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeTheme(PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// a:theme
|
||||
$objWriter->startElement('a:theme');
|
||||
$objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main');
|
||||
$objWriter->writeAttribute('name', 'Office Theme');
|
||||
|
||||
// a:themeElements
|
||||
$objWriter->startElement('a:themeElements');
|
||||
|
||||
// a:clrScheme
|
||||
$objWriter->startElement('a:clrScheme');
|
||||
$objWriter->writeAttribute('name', 'Office');
|
||||
|
||||
// a:dk1
|
||||
$objWriter->startElement('a:dk1');
|
||||
|
||||
// a:sysClr
|
||||
$objWriter->startElement('a:sysClr');
|
||||
$objWriter->writeAttribute('val', 'windowText');
|
||||
$objWriter->writeAttribute('lastClr', '000000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:lt1
|
||||
$objWriter->startElement('a:lt1');
|
||||
|
||||
// a:sysClr
|
||||
$objWriter->startElement('a:sysClr');
|
||||
$objWriter->writeAttribute('val', 'window');
|
||||
$objWriter->writeAttribute('lastClr', 'FFFFFF');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:dk2
|
||||
$this->_writeColourScheme($objWriter);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:fontScheme
|
||||
$objWriter->startElement('a:fontScheme');
|
||||
$objWriter->writeAttribute('name', 'Office');
|
||||
|
||||
// a:majorFont
|
||||
$objWriter->startElement('a:majorFont');
|
||||
$this->_writeFonts($objWriter, 'Cambria', self::$_majorFonts);
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:minorFont
|
||||
$objWriter->startElement('a:minorFont');
|
||||
$this->_writeFonts($objWriter, 'Calibri', self::$_minorFonts);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:fmtScheme
|
||||
$objWriter->startElement('a:fmtScheme');
|
||||
$objWriter->writeAttribute('name', 'Office');
|
||||
|
||||
// a:fillStyleLst
|
||||
$objWriter->startElement('a:fillStyleLst');
|
||||
|
||||
// a:solidFill
|
||||
$objWriter->startElement('a:solidFill');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gradFill
|
||||
$objWriter->startElement('a:gradFill');
|
||||
$objWriter->writeAttribute('rotWithShape', '1');
|
||||
|
||||
// a:gsLst
|
||||
$objWriter->startElement('a:gsLst');
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '0');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:tint
|
||||
$objWriter->startElement('a:tint');
|
||||
$objWriter->writeAttribute('val', '50000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '300000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '35000');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:tint
|
||||
$objWriter->startElement('a:tint');
|
||||
$objWriter->writeAttribute('val', '37000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '300000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '100000');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:tint
|
||||
$objWriter->startElement('a:tint');
|
||||
$objWriter->writeAttribute('val', '15000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '350000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:lin
|
||||
$objWriter->startElement('a:lin');
|
||||
$objWriter->writeAttribute('ang', '16200000');
|
||||
$objWriter->writeAttribute('scaled', '1');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gradFill
|
||||
$objWriter->startElement('a:gradFill');
|
||||
$objWriter->writeAttribute('rotWithShape', '1');
|
||||
|
||||
// a:gsLst
|
||||
$objWriter->startElement('a:gsLst');
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '0');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:shade
|
||||
$objWriter->startElement('a:shade');
|
||||
$objWriter->writeAttribute('val', '51000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '130000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '80000');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:shade
|
||||
$objWriter->startElement('a:shade');
|
||||
$objWriter->writeAttribute('val', '93000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '130000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '100000');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:shade
|
||||
$objWriter->startElement('a:shade');
|
||||
$objWriter->writeAttribute('val', '94000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '135000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:lin
|
||||
$objWriter->startElement('a:lin');
|
||||
$objWriter->writeAttribute('ang', '16200000');
|
||||
$objWriter->writeAttribute('scaled', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:lnStyleLst
|
||||
$objWriter->startElement('a:lnStyleLst');
|
||||
|
||||
// a:ln
|
||||
$objWriter->startElement('a:ln');
|
||||
$objWriter->writeAttribute('w', '9525');
|
||||
$objWriter->writeAttribute('cap', 'flat');
|
||||
$objWriter->writeAttribute('cmpd', 'sng');
|
||||
$objWriter->writeAttribute('algn', 'ctr');
|
||||
|
||||
// a:solidFill
|
||||
$objWriter->startElement('a:solidFill');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:shade
|
||||
$objWriter->startElement('a:shade');
|
||||
$objWriter->writeAttribute('val', '95000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '105000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:prstDash
|
||||
$objWriter->startElement('a:prstDash');
|
||||
$objWriter->writeAttribute('val', 'solid');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:ln
|
||||
$objWriter->startElement('a:ln');
|
||||
$objWriter->writeAttribute('w', '25400');
|
||||
$objWriter->writeAttribute('cap', 'flat');
|
||||
$objWriter->writeAttribute('cmpd', 'sng');
|
||||
$objWriter->writeAttribute('algn', 'ctr');
|
||||
|
||||
// a:solidFill
|
||||
$objWriter->startElement('a:solidFill');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:prstDash
|
||||
$objWriter->startElement('a:prstDash');
|
||||
$objWriter->writeAttribute('val', 'solid');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:ln
|
||||
$objWriter->startElement('a:ln');
|
||||
$objWriter->writeAttribute('w', '38100');
|
||||
$objWriter->writeAttribute('cap', 'flat');
|
||||
$objWriter->writeAttribute('cmpd', 'sng');
|
||||
$objWriter->writeAttribute('algn', 'ctr');
|
||||
|
||||
// a:solidFill
|
||||
$objWriter->startElement('a:solidFill');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:prstDash
|
||||
$objWriter->startElement('a:prstDash');
|
||||
$objWriter->writeAttribute('val', 'solid');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
|
||||
|
||||
// a:effectStyleLst
|
||||
$objWriter->startElement('a:effectStyleLst');
|
||||
|
||||
// a:effectStyle
|
||||
$objWriter->startElement('a:effectStyle');
|
||||
|
||||
// a:effectLst
|
||||
$objWriter->startElement('a:effectLst');
|
||||
|
||||
// a:outerShdw
|
||||
$objWriter->startElement('a:outerShdw');
|
||||
$objWriter->writeAttribute('blurRad', '40000');
|
||||
$objWriter->writeAttribute('dist', '20000');
|
||||
$objWriter->writeAttribute('dir', '5400000');
|
||||
$objWriter->writeAttribute('rotWithShape', '0');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', '000000');
|
||||
|
||||
// a:alpha
|
||||
$objWriter->startElement('a:alpha');
|
||||
$objWriter->writeAttribute('val', '38000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:effectStyle
|
||||
$objWriter->startElement('a:effectStyle');
|
||||
|
||||
// a:effectLst
|
||||
$objWriter->startElement('a:effectLst');
|
||||
|
||||
// a:outerShdw
|
||||
$objWriter->startElement('a:outerShdw');
|
||||
$objWriter->writeAttribute('blurRad', '40000');
|
||||
$objWriter->writeAttribute('dist', '23000');
|
||||
$objWriter->writeAttribute('dir', '5400000');
|
||||
$objWriter->writeAttribute('rotWithShape', '0');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', '000000');
|
||||
|
||||
// a:alpha
|
||||
$objWriter->startElement('a:alpha');
|
||||
$objWriter->writeAttribute('val', '35000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:effectStyle
|
||||
$objWriter->startElement('a:effectStyle');
|
||||
|
||||
// a:effectLst
|
||||
$objWriter->startElement('a:effectLst');
|
||||
|
||||
// a:outerShdw
|
||||
$objWriter->startElement('a:outerShdw');
|
||||
$objWriter->writeAttribute('blurRad', '40000');
|
||||
$objWriter->writeAttribute('dist', '23000');
|
||||
$objWriter->writeAttribute('dir', '5400000');
|
||||
$objWriter->writeAttribute('rotWithShape', '0');
|
||||
|
||||
// a:srgbClr
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', '000000');
|
||||
|
||||
// a:alpha
|
||||
$objWriter->startElement('a:alpha');
|
||||
$objWriter->writeAttribute('val', '35000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:scene3d
|
||||
$objWriter->startElement('a:scene3d');
|
||||
|
||||
// a:camera
|
||||
$objWriter->startElement('a:camera');
|
||||
$objWriter->writeAttribute('prst', 'orthographicFront');
|
||||
|
||||
// a:rot
|
||||
$objWriter->startElement('a:rot');
|
||||
$objWriter->writeAttribute('lat', '0');
|
||||
$objWriter->writeAttribute('lon', '0');
|
||||
$objWriter->writeAttribute('rev', '0');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:lightRig
|
||||
$objWriter->startElement('a:lightRig');
|
||||
$objWriter->writeAttribute('rig', 'threePt');
|
||||
$objWriter->writeAttribute('dir', 't');
|
||||
|
||||
// a:rot
|
||||
$objWriter->startElement('a:rot');
|
||||
$objWriter->writeAttribute('lat', '0');
|
||||
$objWriter->writeAttribute('lon', '0');
|
||||
$objWriter->writeAttribute('rev', '1200000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:sp3d
|
||||
$objWriter->startElement('a:sp3d');
|
||||
|
||||
// a:bevelT
|
||||
$objWriter->startElement('a:bevelT');
|
||||
$objWriter->writeAttribute('w', '63500');
|
||||
$objWriter->writeAttribute('h', '25400');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:bgFillStyleLst
|
||||
$objWriter->startElement('a:bgFillStyleLst');
|
||||
|
||||
// a:solidFill
|
||||
$objWriter->startElement('a:solidFill');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gradFill
|
||||
$objWriter->startElement('a:gradFill');
|
||||
$objWriter->writeAttribute('rotWithShape', '1');
|
||||
|
||||
// a:gsLst
|
||||
$objWriter->startElement('a:gsLst');
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '0');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:tint
|
||||
$objWriter->startElement('a:tint');
|
||||
$objWriter->writeAttribute('val', '40000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '350000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '40000');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:tint
|
||||
$objWriter->startElement('a:tint');
|
||||
$objWriter->writeAttribute('val', '45000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:shade
|
||||
$objWriter->startElement('a:shade');
|
||||
$objWriter->writeAttribute('val', '99000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '350000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '100000');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:shade
|
||||
$objWriter->startElement('a:shade');
|
||||
$objWriter->writeAttribute('val', '20000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '255000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:path
|
||||
$objWriter->startElement('a:path');
|
||||
$objWriter->writeAttribute('path', 'circle');
|
||||
|
||||
// a:fillToRect
|
||||
$objWriter->startElement('a:fillToRect');
|
||||
$objWriter->writeAttribute('l', '50000');
|
||||
$objWriter->writeAttribute('t', '-80000');
|
||||
$objWriter->writeAttribute('r', '50000');
|
||||
$objWriter->writeAttribute('b', '180000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gradFill
|
||||
$objWriter->startElement('a:gradFill');
|
||||
$objWriter->writeAttribute('rotWithShape', '1');
|
||||
|
||||
// a:gsLst
|
||||
$objWriter->startElement('a:gsLst');
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '0');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:tint
|
||||
$objWriter->startElement('a:tint');
|
||||
$objWriter->writeAttribute('val', '80000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '300000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:gs
|
||||
$objWriter->startElement('a:gs');
|
||||
$objWriter->writeAttribute('pos', '100000');
|
||||
|
||||
// a:schemeClr
|
||||
$objWriter->startElement('a:schemeClr');
|
||||
$objWriter->writeAttribute('val', 'phClr');
|
||||
|
||||
// a:shade
|
||||
$objWriter->startElement('a:shade');
|
||||
$objWriter->writeAttribute('val', '30000');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:satMod
|
||||
$objWriter->startElement('a:satMod');
|
||||
$objWriter->writeAttribute('val', '200000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:path
|
||||
$objWriter->startElement('a:path');
|
||||
$objWriter->writeAttribute('path', 'circle');
|
||||
|
||||
// a:fillToRect
|
||||
$objWriter->startElement('a:fillToRect');
|
||||
$objWriter->writeAttribute('l', '50000');
|
||||
$objWriter->writeAttribute('t', '50000');
|
||||
$objWriter->writeAttribute('r', '50000');
|
||||
$objWriter->writeAttribute('b', '50000');
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:objectDefaults
|
||||
$objWriter->writeElement('a:objectDefaults', null);
|
||||
|
||||
// a:extraClrSchemeLst
|
||||
$objWriter->writeElement('a:extraClrSchemeLst', null);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write fonts to XML format
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter
|
||||
* @param string $latinFont
|
||||
* @param array of string $fontSet
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeFonts($objWriter, $latinFont, $fontSet)
|
||||
{
|
||||
// a:latin
|
||||
$objWriter->startElement('a:latin');
|
||||
$objWriter->writeAttribute('typeface', $latinFont);
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:ea
|
||||
$objWriter->startElement('a:ea');
|
||||
$objWriter->writeAttribute('typeface', '');
|
||||
$objWriter->endElement();
|
||||
|
||||
// a:cs
|
||||
$objWriter->startElement('a:cs');
|
||||
$objWriter->writeAttribute('typeface', '');
|
||||
$objWriter->endElement();
|
||||
|
||||
foreach($fontSet as $fontScript => $typeface) {
|
||||
$objWriter->startElement('a:font');
|
||||
$objWriter->writeAttribute('script', $fontScript);
|
||||
$objWriter->writeAttribute('typeface', $typeface);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Write colour scheme to XML format
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeColourScheme($objWriter)
|
||||
{
|
||||
foreach(self::$_colourScheme as $colourName => $colourValue) {
|
||||
$objWriter->startElement('a:'.$colourName);
|
||||
|
||||
$objWriter->startElement('a:srgbClr');
|
||||
$objWriter->writeAttribute('val', $colourValue);
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
456
extend/phpexcel/PHPExcel/Writer/Excel2007/Workbook.php
Executable file
456
extend/phpexcel/PHPExcel/Writer/Excel2007/Workbook.php
Executable file
@ -0,0 +1,456 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_Workbook
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Write workbook to XML format
|
||||
*
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing
|
||||
* @return string XML Output
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function writeWorkbook(PHPExcel $pPHPExcel = null, $recalcRequired = FALSE)
|
||||
{
|
||||
// Create XML writer
|
||||
$objWriter = null;
|
||||
if ($this->getParentWriter()->getUseDiskCaching()) {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
|
||||
} else {
|
||||
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
|
||||
// XML header
|
||||
$objWriter->startDocument('1.0','UTF-8','yes');
|
||||
|
||||
// workbook
|
||||
$objWriter->startElement('workbook');
|
||||
$objWriter->writeAttribute('xml:space', 'preserve');
|
||||
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
|
||||
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
|
||||
// fileVersion
|
||||
$this->_writeFileVersion($objWriter);
|
||||
|
||||
// workbookPr
|
||||
$this->_writeWorkbookPr($objWriter);
|
||||
|
||||
// workbookProtection
|
||||
$this->_writeWorkbookProtection($objWriter, $pPHPExcel);
|
||||
|
||||
// bookViews
|
||||
if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
|
||||
$this->_writeBookViews($objWriter, $pPHPExcel);
|
||||
}
|
||||
|
||||
// sheets
|
||||
$this->_writeSheets($objWriter, $pPHPExcel);
|
||||
|
||||
// definedNames
|
||||
$this->_writeDefinedNames($objWriter, $pPHPExcel);
|
||||
|
||||
// calcPr
|
||||
$this->_writeCalcPr($objWriter,$recalcRequired);
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
// Return
|
||||
return $objWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write file version
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeFileVersion(PHPExcel_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$objWriter->startElement('fileVersion');
|
||||
$objWriter->writeAttribute('appName', 'xl');
|
||||
$objWriter->writeAttribute('lastEdited', '4');
|
||||
$objWriter->writeAttribute('lowestEdited', '4');
|
||||
$objWriter->writeAttribute('rupBuild', '4505');
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write WorkbookPr
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeWorkbookPr(PHPExcel_Shared_XMLWriter $objWriter = null)
|
||||
{
|
||||
$objWriter->startElement('workbookPr');
|
||||
|
||||
if (PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904) {
|
||||
$objWriter->writeAttribute('date1904', '1');
|
||||
}
|
||||
|
||||
$objWriter->writeAttribute('codeName', 'ThisWorkbook');
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write BookViews
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeBookViews(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// bookViews
|
||||
$objWriter->startElement('bookViews');
|
||||
|
||||
// workbookView
|
||||
$objWriter->startElement('workbookView');
|
||||
|
||||
$objWriter->writeAttribute('activeTab', $pPHPExcel->getActiveSheetIndex());
|
||||
$objWriter->writeAttribute('autoFilterDateGrouping', '1');
|
||||
$objWriter->writeAttribute('firstSheet', '0');
|
||||
$objWriter->writeAttribute('minimized', '0');
|
||||
$objWriter->writeAttribute('showHorizontalScroll', '1');
|
||||
$objWriter->writeAttribute('showSheetTabs', '1');
|
||||
$objWriter->writeAttribute('showVerticalScroll', '1');
|
||||
$objWriter->writeAttribute('tabRatio', '600');
|
||||
$objWriter->writeAttribute('visibility', 'visible');
|
||||
|
||||
$objWriter->endElement();
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write WorkbookProtection
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeWorkbookProtection(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
if ($pPHPExcel->getSecurity()->isSecurityEnabled()) {
|
||||
$objWriter->startElement('workbookProtection');
|
||||
$objWriter->writeAttribute('lockRevision', ($pPHPExcel->getSecurity()->getLockRevision() ? 'true' : 'false'));
|
||||
$objWriter->writeAttribute('lockStructure', ($pPHPExcel->getSecurity()->getLockStructure() ? 'true' : 'false'));
|
||||
$objWriter->writeAttribute('lockWindows', ($pPHPExcel->getSecurity()->getLockWindows() ? 'true' : 'false'));
|
||||
|
||||
if ($pPHPExcel->getSecurity()->getRevisionsPassword() != '') {
|
||||
$objWriter->writeAttribute('revisionsPassword', $pPHPExcel->getSecurity()->getRevisionsPassword());
|
||||
}
|
||||
|
||||
if ($pPHPExcel->getSecurity()->getWorkbookPassword() != '') {
|
||||
$objWriter->writeAttribute('workbookPassword', $pPHPExcel->getSecurity()->getWorkbookPassword());
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write calcPr
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeCalcPr(PHPExcel_Shared_XMLWriter $objWriter = null, $recalcRequired = TRUE)
|
||||
{
|
||||
$objWriter->startElement('calcPr');
|
||||
|
||||
// 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
|
||||
// because the file has changed
|
||||
$objWriter->writeAttribute('calcId', '999999');
|
||||
$objWriter->writeAttribute('calcMode', 'auto');
|
||||
// fullCalcOnLoad isn't needed if we've recalculating for the save
|
||||
$objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? 1 : 0);
|
||||
$objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? 0 : 1);
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write sheets
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeSheets(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Write sheets
|
||||
$objWriter->startElement('sheets');
|
||||
$sheetCount = $pPHPExcel->getSheetCount();
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
// sheet
|
||||
$this->_writeSheet(
|
||||
$objWriter,
|
||||
$pPHPExcel->getSheet($i)->getTitle(),
|
||||
($i + 1),
|
||||
($i + 1 + 3),
|
||||
$pPHPExcel->getSheet($i)->getSheetState()
|
||||
);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write sheet
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param string $pSheetname Sheet name
|
||||
* @param int $pSheetId Sheet id
|
||||
* @param int $pRelId Relationship ID
|
||||
* @param string $sheetState Sheet state (visible, hidden, veryHidden)
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeSheet(PHPExcel_Shared_XMLWriter $objWriter = null, $pSheetname = '', $pSheetId = 1, $pRelId = 1, $sheetState = 'visible')
|
||||
{
|
||||
if ($pSheetname != '') {
|
||||
// Write sheet
|
||||
$objWriter->startElement('sheet');
|
||||
$objWriter->writeAttribute('name', $pSheetname);
|
||||
$objWriter->writeAttribute('sheetId', $pSheetId);
|
||||
if ($sheetState != 'visible' && $sheetState != '') {
|
||||
$objWriter->writeAttribute('state', $sheetState);
|
||||
}
|
||||
$objWriter->writeAttribute('r:id', 'rId' . $pRelId);
|
||||
$objWriter->endElement();
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Defined Names
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeDefinedNames(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel = null)
|
||||
{
|
||||
// Write defined names
|
||||
$objWriter->startElement('definedNames');
|
||||
|
||||
// Named ranges
|
||||
if (count($pPHPExcel->getNamedRanges()) > 0) {
|
||||
// Named ranges
|
||||
$this->_writeNamedRanges($objWriter, $pPHPExcel);
|
||||
}
|
||||
|
||||
// Other defined names
|
||||
$sheetCount = $pPHPExcel->getSheetCount();
|
||||
for ($i = 0; $i < $sheetCount; ++$i) {
|
||||
// definedName for autoFilter
|
||||
$this->_writeDefinedNameForAutofilter($objWriter, $pPHPExcel->getSheet($i), $i);
|
||||
|
||||
// definedName for Print_Titles
|
||||
$this->_writeDefinedNameForPrintTitles($objWriter, $pPHPExcel->getSheet($i), $i);
|
||||
|
||||
// definedName for Print_Area
|
||||
$this->_writeDefinedNameForPrintArea($objWriter, $pPHPExcel->getSheet($i), $i);
|
||||
}
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write named ranges
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel $pPHPExcel
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeNamedRanges(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel $pPHPExcel)
|
||||
{
|
||||
// Loop named ranges
|
||||
$namedRanges = $pPHPExcel->getNamedRanges();
|
||||
foreach ($namedRanges as $namedRange) {
|
||||
$this->_writeDefinedNameForNamedRange($objWriter, $namedRange);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Defined Name for named range
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_NamedRange $pNamedRange
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeDefinedNameForNamedRange(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_NamedRange $pNamedRange)
|
||||
{
|
||||
// definedName for named range
|
||||
$objWriter->startElement('definedName');
|
||||
$objWriter->writeAttribute('name', $pNamedRange->getName());
|
||||
if ($pNamedRange->getLocalOnly()) {
|
||||
$objWriter->writeAttribute('localSheetId', $pNamedRange->getScope()->getParent()->getIndex($pNamedRange->getScope()));
|
||||
}
|
||||
|
||||
// Create absolute coordinate and write as raw text
|
||||
$range = PHPExcel_Cell::splitRange($pNamedRange->getRange());
|
||||
for ($i = 0; $i < count($range); $i++) {
|
||||
$range[$i][0] = '\'' . str_replace("'", "''", $pNamedRange->getWorksheet()->getTitle()) . '\'!' . PHPExcel_Cell::absoluteReference($range[$i][0]);
|
||||
if (isset($range[$i][1])) {
|
||||
$range[$i][1] = PHPExcel_Cell::absoluteReference($range[$i][1]);
|
||||
}
|
||||
}
|
||||
$range = PHPExcel_Cell::buildRange($range);
|
||||
|
||||
$objWriter->writeRawData($range);
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Defined Name for autoFilter
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Worksheet $pSheet
|
||||
* @param int $pSheetId
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeDefinedNameForAutofilter(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
|
||||
{
|
||||
// definedName for autoFilter
|
||||
$autoFilterRange = $pSheet->getAutoFilter()->getRange();
|
||||
if (!empty($autoFilterRange)) {
|
||||
$objWriter->startElement('definedName');
|
||||
$objWriter->writeAttribute('name', '_xlnm._FilterDatabase');
|
||||
$objWriter->writeAttribute('localSheetId', $pSheetId);
|
||||
$objWriter->writeAttribute('hidden', '1');
|
||||
|
||||
// Create absolute coordinate and write as raw text
|
||||
$range = PHPExcel_Cell::splitRange($autoFilterRange);
|
||||
$range = $range[0];
|
||||
// Strip any worksheet ref so we can make the cell ref absolute
|
||||
if (strpos($range[0],'!') !== false) {
|
||||
list($ws,$range[0]) = explode('!',$range[0]);
|
||||
}
|
||||
|
||||
$range[0] = PHPExcel_Cell::absoluteCoordinate($range[0]);
|
||||
$range[1] = PHPExcel_Cell::absoluteCoordinate($range[1]);
|
||||
$range = implode(':', $range);
|
||||
|
||||
$objWriter->writeRawData('\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . $range);
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Defined Name for PrintTitles
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Worksheet $pSheet
|
||||
* @param int $pSheetId
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeDefinedNameForPrintTitles(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
|
||||
{
|
||||
// definedName for PrintTitles
|
||||
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
|
||||
$objWriter->startElement('definedName');
|
||||
$objWriter->writeAttribute('name', '_xlnm.Print_Titles');
|
||||
$objWriter->writeAttribute('localSheetId', $pSheetId);
|
||||
|
||||
// Setting string
|
||||
$settingString = '';
|
||||
|
||||
// Columns to repeat
|
||||
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet()) {
|
||||
$repeat = $pSheet->getPageSetup()->getColumnsToRepeatAtLeft();
|
||||
|
||||
$settingString .= '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!$' . $repeat[0] . ':$' . $repeat[1];
|
||||
}
|
||||
|
||||
// Rows to repeat
|
||||
if ($pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
|
||||
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet()) {
|
||||
$settingString .= ',';
|
||||
}
|
||||
|
||||
$repeat = $pSheet->getPageSetup()->getRowsToRepeatAtTop();
|
||||
|
||||
$settingString .= '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!$' . $repeat[0] . ':$' . $repeat[1];
|
||||
}
|
||||
|
||||
$objWriter->writeRawData($settingString);
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write Defined Name for PrintTitles
|
||||
*
|
||||
* @param PHPExcel_Shared_XMLWriter $objWriter XML Writer
|
||||
* @param PHPExcel_Worksheet $pSheet
|
||||
* @param int $pSheetId
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
private function _writeDefinedNameForPrintArea(PHPExcel_Shared_XMLWriter $objWriter = null, PHPExcel_Worksheet $pSheet = null, $pSheetId = 0)
|
||||
{
|
||||
// definedName for PrintArea
|
||||
if ($pSheet->getPageSetup()->isPrintAreaSet()) {
|
||||
$objWriter->startElement('definedName');
|
||||
$objWriter->writeAttribute('name', '_xlnm.Print_Area');
|
||||
$objWriter->writeAttribute('localSheetId', $pSheetId);
|
||||
|
||||
// Setting string
|
||||
$settingString = '';
|
||||
|
||||
// Print area
|
||||
$printArea = PHPExcel_Cell::splitRange($pSheet->getPageSetup()->getPrintArea());
|
||||
|
||||
$chunks = array();
|
||||
foreach ($printArea as $printAreaRect) {
|
||||
$printAreaRect[0] = PHPExcel_Cell::absoluteReference($printAreaRect[0]);
|
||||
$printAreaRect[1] = PHPExcel_Cell::absoluteReference($printAreaRect[1]);
|
||||
$chunks[] = '\'' . str_replace("'", "''", $pSheet->getTitle()) . '\'!' . implode(':', $printAreaRect);
|
||||
}
|
||||
|
||||
$objWriter->writeRawData(implode(',', $chunks));
|
||||
|
||||
$objWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
1220
extend/phpexcel/PHPExcel/Writer/Excel2007/Worksheet.php
Executable file
1220
extend/phpexcel/PHPExcel/Writer/Excel2007/Worksheet.php
Executable file
File diff suppressed because it is too large
Load Diff
81
extend/phpexcel/PHPExcel/Writer/Excel2007/WriterPart.php
Executable file
81
extend/phpexcel/PHPExcel/Writer/Excel2007/WriterPart.php
Executable file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel2007_WriterPart
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel2007
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
abstract class PHPExcel_Writer_Excel2007_WriterPart
|
||||
{
|
||||
/**
|
||||
* Parent IWriter object
|
||||
*
|
||||
* @var PHPExcel_Writer_IWriter
|
||||
*/
|
||||
private $_parentWriter;
|
||||
|
||||
/**
|
||||
* Set parent IWriter object
|
||||
*
|
||||
* @param PHPExcel_Writer_IWriter $pWriter
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function setParentWriter(PHPExcel_Writer_IWriter $pWriter = null) {
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent IWriter object
|
||||
*
|
||||
* @return PHPExcel_Writer_IWriter
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function getParentWriter() {
|
||||
if (!is_null($this->_parentWriter)) {
|
||||
return $this->_parentWriter;
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("No parent PHPExcel_Writer_IWriter assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parent IWriter object
|
||||
*
|
||||
* @param PHPExcel_Writer_IWriter $pWriter
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function __construct(PHPExcel_Writer_IWriter $pWriter = null) {
|
||||
if (!is_null($pWriter)) {
|
||||
$this->_parentWriter = $pWriter;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
935
extend/phpexcel/PHPExcel/Writer/Excel5.php
Executable file
935
extend/phpexcel/PHPExcel/Writer/Excel5.php
Executable file
@ -0,0 +1,935 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel5
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* PHPExcel object
|
||||
*
|
||||
* @var PHPExcel
|
||||
*/
|
||||
private $_phpExcel;
|
||||
|
||||
/**
|
||||
* Total number of shared strings in workbook
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_str_total = 0;
|
||||
|
||||
/**
|
||||
* Number of unique shared strings in workbook
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_str_unique = 0;
|
||||
|
||||
/**
|
||||
* Array of unique shared strings in workbook
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_str_table = array();
|
||||
|
||||
/**
|
||||
* Color cache. Mapping between RGB value and color index.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_colors;
|
||||
|
||||
/**
|
||||
* Formula parser
|
||||
*
|
||||
* @var PHPExcel_Writer_Excel5_Parser
|
||||
*/
|
||||
private $_parser;
|
||||
|
||||
/**
|
||||
* Identifier clusters for drawings. Used in MSODRAWINGGROUP record.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_IDCLs;
|
||||
|
||||
/**
|
||||
* Basic OLE object summary information
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_summaryInformation;
|
||||
|
||||
/**
|
||||
* Extended OLE object document summary information
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_documentSummaryInformation;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Writer_Excel5
|
||||
*
|
||||
* @param PHPExcel $phpExcel PHPExcel object
|
||||
*/
|
||||
public function __construct(PHPExcel $phpExcel) {
|
||||
$this->_phpExcel = $phpExcel;
|
||||
|
||||
$this->_parser = new PHPExcel_Writer_Excel5_Parser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPExcel to file
|
||||
*
|
||||
* @param string $pFilename
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function save($pFilename = null) {
|
||||
|
||||
// garbage collect
|
||||
$this->_phpExcel->garbageCollect();
|
||||
|
||||
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog();
|
||||
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE);
|
||||
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
|
||||
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
|
||||
|
||||
// initialize colors array
|
||||
$this->_colors = array();
|
||||
|
||||
// Initialise workbook writer
|
||||
$this->_writerWorkbook = new PHPExcel_Writer_Excel5_Workbook($this->_phpExcel,
|
||||
$this->_str_total, $this->_str_unique, $this->_str_table,
|
||||
$this->_colors, $this->_parser);
|
||||
|
||||
// Initialise worksheet writers
|
||||
$countSheets = $this->_phpExcel->getSheetCount();
|
||||
for ($i = 0; $i < $countSheets; ++$i) {
|
||||
$this->_writerWorksheets[$i] = new PHPExcel_Writer_Excel5_Worksheet($this->_str_total, $this->_str_unique,
|
||||
$this->_str_table, $this->_colors,
|
||||
$this->_parser,
|
||||
$this->_preCalculateFormulas,
|
||||
$this->_phpExcel->getSheet($i));
|
||||
}
|
||||
|
||||
// build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook.
|
||||
$this->_buildWorksheetEschers();
|
||||
$this->_buildWorkbookEscher();
|
||||
|
||||
// add 15 identical cell style Xfs
|
||||
// for now, we use the first cellXf instead of cellStyleXf
|
||||
$cellXfCollection = $this->_phpExcel->getCellXfCollection();
|
||||
for ($i = 0; $i < 15; ++$i) {
|
||||
$this->_writerWorkbook->addXfWriter($cellXfCollection[0], true);
|
||||
}
|
||||
|
||||
// add all the cell Xfs
|
||||
foreach ($this->_phpExcel->getCellXfCollection() as $style) {
|
||||
$this->_writerWorkbook->addXfWriter($style, false);
|
||||
}
|
||||
|
||||
// add fonts from rich text eleemnts
|
||||
for ($i = 0; $i < $countSheets; ++$i) {
|
||||
foreach ($this->_writerWorksheets[$i]->_phpSheet->getCellCollection() as $cellID) {
|
||||
$cell = $this->_writerWorksheets[$i]->_phpSheet->getCell($cellID);
|
||||
$cVal = $cell->getValue();
|
||||
if ($cVal instanceof PHPExcel_RichText) {
|
||||
$elements = $cVal->getRichTextElements();
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof PHPExcel_RichText_Run) {
|
||||
$font = $element->getFont();
|
||||
$this->_writerWorksheets[$i]->_fntHashIndex[$font->getHashCode()] = $this->_writerWorkbook->_addFont($font);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// initialize OLE file
|
||||
$workbookStreamName = 'Workbook';
|
||||
$OLE = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs($workbookStreamName));
|
||||
|
||||
// Write the worksheet streams before the global workbook stream,
|
||||
// because the byte sizes of these are needed in the global workbook stream
|
||||
$worksheetSizes = array();
|
||||
for ($i = 0; $i < $countSheets; ++$i) {
|
||||
$this->_writerWorksheets[$i]->close();
|
||||
$worksheetSizes[] = $this->_writerWorksheets[$i]->_datasize;
|
||||
}
|
||||
|
||||
// add binary data for global workbook stream
|
||||
$OLE->append($this->_writerWorkbook->writeWorkbook($worksheetSizes));
|
||||
|
||||
// add binary data for sheet streams
|
||||
for ($i = 0; $i < $countSheets; ++$i) {
|
||||
$OLE->append($this->_writerWorksheets[$i]->getData());
|
||||
}
|
||||
|
||||
$this->_documentSummaryInformation = $this->_writeDocumentSummaryInformation();
|
||||
// initialize OLE Document Summary Information
|
||||
if(isset($this->_documentSummaryInformation) && !empty($this->_documentSummaryInformation)){
|
||||
$OLE_DocumentSummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'DocumentSummaryInformation'));
|
||||
$OLE_DocumentSummaryInformation->append($this->_documentSummaryInformation);
|
||||
}
|
||||
|
||||
$this->_summaryInformation = $this->_writeSummaryInformation();
|
||||
// initialize OLE Summary Information
|
||||
if(isset($this->_summaryInformation) && !empty($this->_summaryInformation)){
|
||||
$OLE_SummaryInformation = new PHPExcel_Shared_OLE_PPS_File(PHPExcel_Shared_OLE::Asc2Ucs(chr(5) . 'SummaryInformation'));
|
||||
$OLE_SummaryInformation->append($this->_summaryInformation);
|
||||
}
|
||||
|
||||
// define OLE Parts
|
||||
$arrRootData = array($OLE);
|
||||
// initialize OLE Properties file
|
||||
if(isset($OLE_SummaryInformation)){
|
||||
$arrRootData[] = $OLE_SummaryInformation;
|
||||
}
|
||||
// initialize OLE Extended Properties file
|
||||
if(isset($OLE_DocumentSummaryInformation)){
|
||||
$arrRootData[] = $OLE_DocumentSummaryInformation;
|
||||
}
|
||||
|
||||
$root = new PHPExcel_Shared_OLE_PPS_Root(time(), time(), $arrRootData);
|
||||
// save the OLE file
|
||||
$res = $root->save($pFilename);
|
||||
|
||||
PHPExcel_Calculation_Functions::setReturnDateType($saveDateReturnType);
|
||||
PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog($saveDebugLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set temporary storage directory
|
||||
*
|
||||
* @deprecated
|
||||
* @param string $pValue Temporary storage directory
|
||||
* @throws PHPExcel_Writer_Exception when directory does not exist
|
||||
* @return PHPExcel_Writer_Excel5
|
||||
*/
|
||||
public function setTempDir($pValue = '') {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Worksheet Escher objects
|
||||
*
|
||||
*/
|
||||
private function _buildWorksheetEschers()
|
||||
{
|
||||
// 1-based index to BstoreContainer
|
||||
$blipIndex = 0;
|
||||
$lastReducedSpId = 0;
|
||||
$lastSpId = 0;
|
||||
|
||||
foreach ($this->_phpExcel->getAllsheets() as $sheet) {
|
||||
// sheet index
|
||||
$sheetIndex = $sheet->getParent()->getIndex($sheet);
|
||||
|
||||
$escher = null;
|
||||
|
||||
// check if there are any shapes for this sheet
|
||||
$filterRange = $sheet->getAutoFilter()->getRange();
|
||||
if (count($sheet->getDrawingCollection()) == 0 && empty($filterRange)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// create intermediate Escher object
|
||||
$escher = new PHPExcel_Shared_Escher();
|
||||
|
||||
// dgContainer
|
||||
$dgContainer = new PHPExcel_Shared_Escher_DgContainer();
|
||||
|
||||
// set the drawing index (we use sheet index + 1)
|
||||
$dgId = $sheet->getParent()->getIndex($sheet) + 1;
|
||||
$dgContainer->setDgId($dgId);
|
||||
$escher->setDgContainer($dgContainer);
|
||||
|
||||
// spgrContainer
|
||||
$spgrContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer();
|
||||
$dgContainer->setSpgrContainer($spgrContainer);
|
||||
|
||||
// add one shape which is the group shape
|
||||
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
|
||||
$spContainer->setSpgr(true);
|
||||
$spContainer->setSpType(0);
|
||||
$spContainer->setSpId(($sheet->getParent()->getIndex($sheet) + 1) << 10);
|
||||
$spgrContainer->addChild($spContainer);
|
||||
|
||||
// add the shapes
|
||||
|
||||
$countShapes[$sheetIndex] = 0; // count number of shapes (minus group shape), in sheet
|
||||
|
||||
foreach ($sheet->getDrawingCollection() as $drawing) {
|
||||
++$blipIndex;
|
||||
|
||||
++$countShapes[$sheetIndex];
|
||||
|
||||
// add the shape
|
||||
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
|
||||
|
||||
// set the shape type
|
||||
$spContainer->setSpType(0x004B);
|
||||
// set the shape flag
|
||||
$spContainer->setSpFlag(0x02);
|
||||
|
||||
// set the shape index (we combine 1-based sheet index and $countShapes to create unique shape index)
|
||||
$reducedSpId = $countShapes[$sheetIndex];
|
||||
$spId = $reducedSpId
|
||||
| ($sheet->getParent()->getIndex($sheet) + 1) << 10;
|
||||
$spContainer->setSpId($spId);
|
||||
|
||||
// keep track of last reducedSpId
|
||||
$lastReducedSpId = $reducedSpId;
|
||||
|
||||
// keep track of last spId
|
||||
$lastSpId = $spId;
|
||||
|
||||
// set the BLIP index
|
||||
$spContainer->setOPT(0x4104, $blipIndex);
|
||||
|
||||
// set coordinates and offsets, client anchor
|
||||
$coordinates = $drawing->getCoordinates();
|
||||
$offsetX = $drawing->getOffsetX();
|
||||
$offsetY = $drawing->getOffsetY();
|
||||
$width = $drawing->getWidth();
|
||||
$height = $drawing->getHeight();
|
||||
|
||||
$twoAnchor = PHPExcel_Shared_Excel5::oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height);
|
||||
|
||||
$spContainer->setStartCoordinates($twoAnchor['startCoordinates']);
|
||||
$spContainer->setStartOffsetX($twoAnchor['startOffsetX']);
|
||||
$spContainer->setStartOffsetY($twoAnchor['startOffsetY']);
|
||||
$spContainer->setEndCoordinates($twoAnchor['endCoordinates']);
|
||||
$spContainer->setEndOffsetX($twoAnchor['endOffsetX']);
|
||||
$spContainer->setEndOffsetY($twoAnchor['endOffsetY']);
|
||||
|
||||
$spgrContainer->addChild($spContainer);
|
||||
}
|
||||
|
||||
// AutoFilters
|
||||
if(!empty($filterRange)){
|
||||
$rangeBounds = PHPExcel_Cell::rangeBoundaries($filterRange);
|
||||
$iNumColStart = $rangeBounds[0][0];
|
||||
$iNumColEnd = $rangeBounds[1][0];
|
||||
|
||||
$iInc = $iNumColStart;
|
||||
while($iInc <= $iNumColEnd){
|
||||
++$countShapes[$sheetIndex];
|
||||
|
||||
// create an Drawing Object for the dropdown
|
||||
$oDrawing = new PHPExcel_Worksheet_BaseDrawing();
|
||||
// get the coordinates of drawing
|
||||
$cDrawing = PHPExcel_Cell::stringFromColumnIndex($iInc - 1) . $rangeBounds[0][1];
|
||||
$oDrawing->setCoordinates($cDrawing);
|
||||
$oDrawing->setWorksheet($sheet);
|
||||
|
||||
// add the shape
|
||||
$spContainer = new PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer();
|
||||
// set the shape type
|
||||
$spContainer->setSpType(0x00C9);
|
||||
// set the shape flag
|
||||
$spContainer->setSpFlag(0x01);
|
||||
|
||||
// set the shape index (we combine 1-based sheet index and $countShapes to create unique shape index)
|
||||
$reducedSpId = $countShapes[$sheetIndex];
|
||||
$spId = $reducedSpId
|
||||
| ($sheet->getParent()->getIndex($sheet) + 1) << 10;
|
||||
$spContainer->setSpId($spId);
|
||||
|
||||
// keep track of last reducedSpId
|
||||
$lastReducedSpId = $reducedSpId;
|
||||
|
||||
// keep track of last spId
|
||||
$lastSpId = $spId;
|
||||
|
||||
$spContainer->setOPT(0x007F, 0x01040104); // Protection -> fLockAgainstGrouping
|
||||
$spContainer->setOPT(0x00BF, 0x00080008); // Text -> fFitTextToShape
|
||||
$spContainer->setOPT(0x01BF, 0x00010000); // Fill Style -> fNoFillHitTest
|
||||
$spContainer->setOPT(0x01FF, 0x00080000); // Line Style -> fNoLineDrawDash
|
||||
$spContainer->setOPT(0x03BF, 0x000A0000); // Group Shape -> fPrint
|
||||
|
||||
// set coordinates and offsets, client anchor
|
||||
$endCoordinates = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::stringFromColumnIndex($iInc - 1));
|
||||
$endCoordinates .= $rangeBounds[0][1] + 1;
|
||||
|
||||
$spContainer->setStartCoordinates($cDrawing);
|
||||
$spContainer->setStartOffsetX(0);
|
||||
$spContainer->setStartOffsetY(0);
|
||||
$spContainer->setEndCoordinates($endCoordinates);
|
||||
$spContainer->setEndOffsetX(0);
|
||||
$spContainer->setEndOffsetY(0);
|
||||
|
||||
$spgrContainer->addChild($spContainer);
|
||||
$iInc++;
|
||||
}
|
||||
}
|
||||
|
||||
// identifier clusters, used for workbook Escher object
|
||||
$this->_IDCLs[$dgId] = $lastReducedSpId;
|
||||
|
||||
// set last shape index
|
||||
$dgContainer->setLastSpId($lastSpId);
|
||||
|
||||
// set the Escher object
|
||||
$this->_writerWorksheets[$sheetIndex]->setEscher($escher);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Escher object corresponding to the MSODRAWINGGROUP record
|
||||
*/
|
||||
private function _buildWorkbookEscher()
|
||||
{
|
||||
$escher = null;
|
||||
|
||||
// any drawings in this workbook?
|
||||
$found = false;
|
||||
foreach ($this->_phpExcel->getAllSheets() as $sheet) {
|
||||
if (count($sheet->getDrawingCollection()) > 0) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// nothing to do if there are no drawings
|
||||
if (!$found) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if we reach here, then there are drawings in the workbook
|
||||
$escher = new PHPExcel_Shared_Escher();
|
||||
|
||||
// dggContainer
|
||||
$dggContainer = new PHPExcel_Shared_Escher_DggContainer();
|
||||
$escher->setDggContainer($dggContainer);
|
||||
|
||||
// set IDCLs (identifier clusters)
|
||||
$dggContainer->setIDCLs($this->_IDCLs);
|
||||
|
||||
// this loop is for determining maximum shape identifier of all drawing
|
||||
$spIdMax = 0;
|
||||
$totalCountShapes = 0;
|
||||
$countDrawings = 0;
|
||||
|
||||
foreach ($this->_phpExcel->getAllsheets() as $sheet) {
|
||||
$sheetCountShapes = 0; // count number of shapes (minus group shape), in sheet
|
||||
|
||||
if (count($sheet->getDrawingCollection()) > 0) {
|
||||
++$countDrawings;
|
||||
|
||||
foreach ($sheet->getDrawingCollection() as $drawing) {
|
||||
++$sheetCountShapes;
|
||||
++$totalCountShapes;
|
||||
|
||||
$spId = $sheetCountShapes
|
||||
| ($this->_phpExcel->getIndex($sheet) + 1) << 10;
|
||||
$spIdMax = max($spId, $spIdMax);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dggContainer->setSpIdMax($spIdMax + 1);
|
||||
$dggContainer->setCDgSaved($countDrawings);
|
||||
$dggContainer->setCSpSaved($totalCountShapes + $countDrawings); // total number of shapes incl. one group shapes per drawing
|
||||
|
||||
// bstoreContainer
|
||||
$bstoreContainer = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer();
|
||||
$dggContainer->setBstoreContainer($bstoreContainer);
|
||||
|
||||
// the BSE's (all the images)
|
||||
foreach ($this->_phpExcel->getAllsheets() as $sheet) {
|
||||
foreach ($sheet->getDrawingCollection() as $drawing) {
|
||||
if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
|
||||
|
||||
$filename = $drawing->getPath();
|
||||
|
||||
list($imagesx, $imagesy, $imageFormat) = getimagesize($filename);
|
||||
|
||||
switch ($imageFormat) {
|
||||
|
||||
case 1: // GIF, not supported by BIFF8, we convert to PNG
|
||||
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
|
||||
ob_start();
|
||||
imagepng(imagecreatefromgif($filename));
|
||||
$blipData = ob_get_contents();
|
||||
ob_end_clean();
|
||||
break;
|
||||
|
||||
case 2: // JPEG
|
||||
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
|
||||
$blipData = file_get_contents($filename);
|
||||
break;
|
||||
|
||||
case 3: // PNG
|
||||
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
|
||||
$blipData = file_get_contents($filename);
|
||||
break;
|
||||
|
||||
case 6: // Windows DIB (BMP), we convert to PNG
|
||||
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
|
||||
ob_start();
|
||||
imagepng(PHPExcel_Shared_Drawing::imagecreatefrombmp($filename));
|
||||
$blipData = ob_get_contents();
|
||||
ob_end_clean();
|
||||
break;
|
||||
|
||||
default: continue 2;
|
||||
|
||||
}
|
||||
|
||||
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
|
||||
$blip->setData($blipData);
|
||||
|
||||
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
|
||||
$BSE->setBlipType($blipType);
|
||||
$BSE->setBlip($blip);
|
||||
|
||||
$bstoreContainer->addBSE($BSE);
|
||||
|
||||
} else if ($drawing instanceof PHPExcel_Worksheet_MemoryDrawing) {
|
||||
|
||||
switch ($drawing->getRenderingFunction()) {
|
||||
|
||||
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_JPEG:
|
||||
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG;
|
||||
$renderingFunction = 'imagejpeg';
|
||||
break;
|
||||
|
||||
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_GIF:
|
||||
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_PNG:
|
||||
case PHPExcel_Worksheet_MemoryDrawing::RENDERING_DEFAULT:
|
||||
$blipType = PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG;
|
||||
$renderingFunction = 'imagepng';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
call_user_func($renderingFunction, $drawing->getImageResource());
|
||||
$blipData = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$blip = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip();
|
||||
$blip->setData($blipData);
|
||||
|
||||
$BSE = new PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE();
|
||||
$BSE->setBlipType($blipType);
|
||||
$BSE->setBlip($blip);
|
||||
|
||||
$bstoreContainer->addBSE($BSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the Escher object
|
||||
$this->_writerWorkbook->setEscher($escher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the OLE Part for DocumentSummary Information
|
||||
* @return string
|
||||
*/
|
||||
private function _writeDocumentSummaryInformation(){
|
||||
|
||||
// offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
|
||||
$data = pack('v', 0xFFFE);
|
||||
// offset: 2; size: 2;
|
||||
$data .= pack('v', 0x0000);
|
||||
// offset: 4; size: 2; OS version
|
||||
$data .= pack('v', 0x0106);
|
||||
// offset: 6; size: 2; OS indicator
|
||||
$data .= pack('v', 0x0002);
|
||||
// offset: 8; size: 16
|
||||
$data .= pack('VVVV', 0x00, 0x00, 0x00, 0x00);
|
||||
// offset: 24; size: 4; section count
|
||||
$data .= pack('V', 0x0001);
|
||||
|
||||
// offset: 28; size: 16; first section's class id: 02 d5 cd d5 9c 2e 1b 10 93 97 08 00 2b 2c f9 ae
|
||||
$data .= pack('vvvvvvvv', 0xD502, 0xD5CD, 0x2E9C, 0x101B, 0x9793, 0x0008, 0x2C2B, 0xAEF9);
|
||||
// offset: 44; size: 4; offset of the start
|
||||
$data .= pack('V', 0x30);
|
||||
|
||||
// SECTION
|
||||
$dataSection = array();
|
||||
$dataSection_NumProps = 0;
|
||||
$dataSection_Summary = '';
|
||||
$dataSection_Content = '';
|
||||
|
||||
// GKPIDDSI_CODEPAGE: CodePage
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x01),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x02), // 2 byte signed integer
|
||||
'data' => array('data' => 1252));
|
||||
$dataSection_NumProps++;
|
||||
|
||||
// GKPIDDSI_CATEGORY : Category
|
||||
if($this->_phpExcel->getProperties()->getCategory()){
|
||||
$dataProp = $this->_phpExcel->getProperties()->getCategory();
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x1E),
|
||||
'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
}
|
||||
// GKPIDDSI_VERSION :Version of the application that wrote the property storage
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x17),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x03),
|
||||
'data' => array('pack' => 'V', 'data' => 0x000C0000));
|
||||
$dataSection_NumProps++;
|
||||
// GKPIDDSI_SCALE : FALSE
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0B),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x0B),
|
||||
'data' => array('data' => false));
|
||||
$dataSection_NumProps++;
|
||||
// GKPIDDSI_LINKSDIRTY : True if any of the values for the linked properties have changed outside of the application
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x10),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x0B),
|
||||
'data' => array('data' => false));
|
||||
$dataSection_NumProps++;
|
||||
// GKPIDDSI_SHAREDOC : FALSE
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x13),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x0B),
|
||||
'data' => array('data' => false));
|
||||
$dataSection_NumProps++;
|
||||
// GKPIDDSI_HYPERLINKSCHANGED : True if any of the values for the _PID_LINKS (hyperlink text) have changed outside of the application
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x16),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x0B),
|
||||
'data' => array('data' => false));
|
||||
$dataSection_NumProps++;
|
||||
|
||||
// GKPIDDSI_DOCSPARTS
|
||||
// MS-OSHARED p75 (2.3.3.2.2.1)
|
||||
// Structure is VtVecUnalignedLpstrValue (2.3.3.1.9)
|
||||
// cElements
|
||||
$dataProp = pack('v', 0x0001);
|
||||
$dataProp .= pack('v', 0x0000);
|
||||
// array of UnalignedLpstr
|
||||
// cch
|
||||
$dataProp .= pack('v', 0x000A);
|
||||
$dataProp .= pack('v', 0x0000);
|
||||
// value
|
||||
$dataProp .= 'Worksheet'.chr(0);
|
||||
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0D),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x101E),
|
||||
'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
|
||||
// GKPIDDSI_HEADINGPAIR
|
||||
// VtVecHeadingPairValue
|
||||
// cElements
|
||||
$dataProp = pack('v', 0x0002);
|
||||
$dataProp .= pack('v', 0x0000);
|
||||
// Array of vtHeadingPair
|
||||
// vtUnalignedString - headingString
|
||||
// stringType
|
||||
$dataProp .= pack('v', 0x001E);
|
||||
// padding
|
||||
$dataProp .= pack('v', 0x0000);
|
||||
// UnalignedLpstr
|
||||
// cch
|
||||
$dataProp .= pack('v', 0x0013);
|
||||
$dataProp .= pack('v', 0x0000);
|
||||
// value
|
||||
$dataProp .= 'Feuilles de calcul';
|
||||
// vtUnalignedString - headingParts
|
||||
// wType : 0x0003 = 32 bit signed integer
|
||||
$dataProp .= pack('v', 0x0300);
|
||||
// padding
|
||||
$dataProp .= pack('v', 0x0000);
|
||||
// value
|
||||
$dataProp .= pack('v', 0x0100);
|
||||
$dataProp .= pack('v', 0x0000);
|
||||
$dataProp .= pack('v', 0x0000);
|
||||
$dataProp .= pack('v', 0x0000);
|
||||
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0C),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x100C),
|
||||
'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
|
||||
// 4 Section Length
|
||||
// 4 Property count
|
||||
// 8 * $dataSection_NumProps (8 = ID (4) + OffSet(4))
|
||||
$dataSection_Content_Offset = 8 + $dataSection_NumProps * 8;
|
||||
foreach ($dataSection as $dataProp){
|
||||
// Summary
|
||||
$dataSection_Summary .= pack($dataProp['summary']['pack'], $dataProp['summary']['data']);
|
||||
// Offset
|
||||
$dataSection_Summary .= pack($dataProp['offset']['pack'], $dataSection_Content_Offset);
|
||||
// DataType
|
||||
$dataSection_Content .= pack($dataProp['type']['pack'], $dataProp['type']['data']);
|
||||
// Data
|
||||
if($dataProp['type']['data'] == 0x02){ // 2 byte signed integer
|
||||
$dataSection_Content .= pack('V', $dataProp['data']['data']);
|
||||
|
||||
$dataSection_Content_Offset += 4 + 4;
|
||||
}
|
||||
elseif($dataProp['type']['data'] == 0x03){ // 4 byte signed integer
|
||||
$dataSection_Content .= pack('V', $dataProp['data']['data']);
|
||||
|
||||
$dataSection_Content_Offset += 4 + 4;
|
||||
}
|
||||
elseif($dataProp['type']['data'] == 0x0B){ // Boolean
|
||||
if($dataProp['data']['data'] == false){
|
||||
$dataSection_Content .= pack('V', 0x0000);
|
||||
} else {
|
||||
$dataSection_Content .= pack('V', 0x0001);
|
||||
}
|
||||
$dataSection_Content_Offset += 4 + 4;
|
||||
}
|
||||
elseif($dataProp['type']['data'] == 0x1E){ // null-terminated string prepended by dword string length
|
||||
// Null-terminated string
|
||||
$dataProp['data']['data'] .= chr(0);
|
||||
$dataProp['data']['length'] += 1;
|
||||
// Complete the string with null string for being a %4
|
||||
$dataProp['data']['length'] = $dataProp['data']['length'] + ((4 - $dataProp['data']['length'] % 4)==4 ? 0 : (4 - $dataProp['data']['length'] % 4));
|
||||
$dataProp['data']['data'] = str_pad($dataProp['data']['data'], $dataProp['data']['length'], chr(0), STR_PAD_RIGHT);
|
||||
|
||||
$dataSection_Content .= pack('V', $dataProp['data']['length']);
|
||||
$dataSection_Content .= $dataProp['data']['data'];
|
||||
|
||||
$dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']);
|
||||
}
|
||||
elseif($dataProp['type']['data'] == 0x40){ // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
|
||||
$dataSection_Content .= $dataProp['data']['data'];
|
||||
|
||||
$dataSection_Content_Offset += 4 + 8;
|
||||
}
|
||||
else {
|
||||
// Data Type Not Used at the moment
|
||||
$dataSection_Content .= $dataProp['data']['data'];
|
||||
|
||||
$dataSection_Content_Offset += 4 + $dataProp['data']['length'];
|
||||
}
|
||||
}
|
||||
// Now $dataSection_Content_Offset contains the size of the content
|
||||
|
||||
// section header
|
||||
// offset: $secOffset; size: 4; section length
|
||||
// + x Size of the content (summary + content)
|
||||
$data .= pack('V', $dataSection_Content_Offset);
|
||||
// offset: $secOffset+4; size: 4; property count
|
||||
$data .= pack('V', $dataSection_NumProps);
|
||||
// Section Summary
|
||||
$data .= $dataSection_Summary;
|
||||
// Section Content
|
||||
$data .= $dataSection_Content;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the OLE Part for Summary Information
|
||||
* @return string
|
||||
*/
|
||||
private function _writeSummaryInformation(){
|
||||
// offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark)
|
||||
$data = pack('v', 0xFFFE);
|
||||
// offset: 2; size: 2;
|
||||
$data .= pack('v', 0x0000);
|
||||
// offset: 4; size: 2; OS version
|
||||
$data .= pack('v', 0x0106);
|
||||
// offset: 6; size: 2; OS indicator
|
||||
$data .= pack('v', 0x0002);
|
||||
// offset: 8; size: 16
|
||||
$data .= pack('VVVV', 0x00, 0x00, 0x00, 0x00);
|
||||
// offset: 24; size: 4; section count
|
||||
$data .= pack('V', 0x0001);
|
||||
|
||||
// offset: 28; size: 16; first section's class id: e0 85 9f f2 f9 4f 68 10 ab 91 08 00 2b 27 b3 d9
|
||||
$data .= pack('vvvvvvvv', 0x85E0, 0xF29F, 0x4FF9, 0x1068, 0x91AB, 0x0008, 0x272B, 0xD9B3);
|
||||
// offset: 44; size: 4; offset of the start
|
||||
$data .= pack('V', 0x30);
|
||||
|
||||
// SECTION
|
||||
$dataSection = array();
|
||||
$dataSection_NumProps = 0;
|
||||
$dataSection_Summary = '';
|
||||
$dataSection_Content = '';
|
||||
|
||||
// CodePage : CP-1252
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x01),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x02), // 2 byte signed integer
|
||||
'data' => array('data' => 1252));
|
||||
$dataSection_NumProps++;
|
||||
|
||||
// Title
|
||||
if($this->_phpExcel->getProperties()->getTitle()){
|
||||
$dataProp = $this->_phpExcel->getProperties()->getTitle();
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x02),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length
|
||||
'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
}
|
||||
// Subject
|
||||
if($this->_phpExcel->getProperties()->getSubject()){
|
||||
$dataProp = $this->_phpExcel->getProperties()->getSubject();
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x03),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length
|
||||
'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
}
|
||||
// Author (Creator)
|
||||
if($this->_phpExcel->getProperties()->getCreator()){
|
||||
$dataProp = $this->_phpExcel->getProperties()->getCreator();
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x04),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length
|
||||
'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
}
|
||||
// Keywords
|
||||
if($this->_phpExcel->getProperties()->getKeywords()){
|
||||
$dataProp = $this->_phpExcel->getProperties()->getKeywords();
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x05),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length
|
||||
'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
}
|
||||
// Comments (Description)
|
||||
if($this->_phpExcel->getProperties()->getDescription()){
|
||||
$dataProp = $this->_phpExcel->getProperties()->getDescription();
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x06),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length
|
||||
'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
}
|
||||
// Last Saved By (LastModifiedBy)
|
||||
if($this->_phpExcel->getProperties()->getLastModifiedBy()){
|
||||
$dataProp = $this->_phpExcel->getProperties()->getLastModifiedBy();
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x08),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x1E), // null-terminated string prepended by dword string length
|
||||
'data' => array('data' => $dataProp, 'length' => strlen($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
}
|
||||
// Created Date/Time
|
||||
if($this->_phpExcel->getProperties()->getCreated()){
|
||||
$dataProp = $this->_phpExcel->getProperties()->getCreated();
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0C),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x40), // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
|
||||
'data' => array('data' => PHPExcel_Shared_OLE::LocalDate2OLE($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
}
|
||||
// Modified Date/Time
|
||||
if($this->_phpExcel->getProperties()->getModified()){
|
||||
$dataProp = $this->_phpExcel->getProperties()->getModified();
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x0D),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x40), // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
|
||||
'data' => array('data' => PHPExcel_Shared_OLE::LocalDate2OLE($dataProp)));
|
||||
$dataSection_NumProps++;
|
||||
}
|
||||
// Security
|
||||
$dataSection[] = array('summary'=> array('pack' => 'V', 'data' => 0x13),
|
||||
'offset' => array('pack' => 'V'),
|
||||
'type' => array('pack' => 'V', 'data' => 0x03), // 4 byte signed integer
|
||||
'data' => array('data' => 0x00));
|
||||
$dataSection_NumProps++;
|
||||
|
||||
|
||||
// 4 Section Length
|
||||
// 4 Property count
|
||||
// 8 * $dataSection_NumProps (8 = ID (4) + OffSet(4))
|
||||
$dataSection_Content_Offset = 8 + $dataSection_NumProps * 8;
|
||||
foreach ($dataSection as $dataProp){
|
||||
// Summary
|
||||
$dataSection_Summary .= pack($dataProp['summary']['pack'], $dataProp['summary']['data']);
|
||||
// Offset
|
||||
$dataSection_Summary .= pack($dataProp['offset']['pack'], $dataSection_Content_Offset);
|
||||
// DataType
|
||||
$dataSection_Content .= pack($dataProp['type']['pack'], $dataProp['type']['data']);
|
||||
// Data
|
||||
if($dataProp['type']['data'] == 0x02){ // 2 byte signed integer
|
||||
$dataSection_Content .= pack('V', $dataProp['data']['data']);
|
||||
|
||||
$dataSection_Content_Offset += 4 + 4;
|
||||
}
|
||||
elseif($dataProp['type']['data'] == 0x03){ // 4 byte signed integer
|
||||
$dataSection_Content .= pack('V', $dataProp['data']['data']);
|
||||
|
||||
$dataSection_Content_Offset += 4 + 4;
|
||||
}
|
||||
elseif($dataProp['type']['data'] == 0x1E){ // null-terminated string prepended by dword string length
|
||||
// Null-terminated string
|
||||
$dataProp['data']['data'] .= chr(0);
|
||||
$dataProp['data']['length'] += 1;
|
||||
// Complete the string with null string for being a %4
|
||||
$dataProp['data']['length'] = $dataProp['data']['length'] + ((4 - $dataProp['data']['length'] % 4)==4 ? 0 : (4 - $dataProp['data']['length'] % 4));
|
||||
$dataProp['data']['data'] = str_pad($dataProp['data']['data'], $dataProp['data']['length'], chr(0), STR_PAD_RIGHT);
|
||||
|
||||
$dataSection_Content .= pack('V', $dataProp['data']['length']);
|
||||
$dataSection_Content .= $dataProp['data']['data'];
|
||||
|
||||
$dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']);
|
||||
}
|
||||
elseif($dataProp['type']['data'] == 0x40){ // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
|
||||
$dataSection_Content .= $dataProp['data']['data'];
|
||||
|
||||
$dataSection_Content_Offset += 4 + 8;
|
||||
}
|
||||
else {
|
||||
// Data Type Not Used at the moment
|
||||
}
|
||||
}
|
||||
// Now $dataSection_Content_Offset contains the size of the content
|
||||
|
||||
// section header
|
||||
// offset: $secOffset; size: 4; section length
|
||||
// + x Size of the content (summary + content)
|
||||
$data .= pack('V', $dataSection_Content_Offset);
|
||||
// offset: $secOffset+4; size: 4; property count
|
||||
$data .= pack('V', $dataSection_NumProps);
|
||||
// Section Summary
|
||||
$data .= $dataSection_Summary;
|
||||
// Section Content
|
||||
$data .= $dataSection_Content;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
255
extend/phpexcel/PHPExcel/Writer/Excel5/BIFFwriter.php
Executable file
255
extend/phpexcel/PHPExcel/Writer/Excel5/BIFFwriter.php
Executable file
@ -0,0 +1,255 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
// Original file header of PEAR::Spreadsheet_Excel_Writer_BIFFwriter (used as the base for this class):
|
||||
// -----------------------------------------------------------------------------------------
|
||||
// * Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
|
||||
// *
|
||||
// * The majority of this is _NOT_ my code. I simply ported it from the
|
||||
// * PERL Spreadsheet::WriteExcel module.
|
||||
// *
|
||||
// * The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
// * <jmcnamara@cpan.org>
|
||||
// *
|
||||
// * I _DO_ maintain this code, and John McNamara has nothing to do with the
|
||||
// * porting of this code to PHP. Any questions directly related to this
|
||||
// * class library should be directed to me.
|
||||
// *
|
||||
// * License Information:
|
||||
// *
|
||||
// * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
// * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
|
||||
// *
|
||||
// * This library is free software; you can redistribute it and/or
|
||||
// * modify it under the terms of the GNU Lesser General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2.1 of the License, or (at your option) any later version.
|
||||
// *
|
||||
// * This library is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// * Lesser General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU Lesser General Public
|
||||
// * License along with this library; if not, write to the Free Software
|
||||
// * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
// */
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel5_BIFFwriter
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel5_BIFFwriter
|
||||
{
|
||||
/**
|
||||
* The byte order of this architecture. 0 => little endian, 1 => big endian
|
||||
* @var integer
|
||||
*/
|
||||
private static $_byte_order;
|
||||
|
||||
/**
|
||||
* The string containing the data of the BIFF stream
|
||||
* @var string
|
||||
*/
|
||||
public $_data;
|
||||
|
||||
/**
|
||||
* The size of the data in bytes. Should be the same as strlen($this->_data)
|
||||
* @var integer
|
||||
*/
|
||||
public $_datasize;
|
||||
|
||||
/**
|
||||
* The maximum length for a BIFF record (excluding record header and length field). See _addContinue()
|
||||
* @var integer
|
||||
* @see _addContinue()
|
||||
*/
|
||||
public $_limit = 8224;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_data = '';
|
||||
$this->_datasize = 0;
|
||||
// $this->_limit = 8224;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the byte order and store it as class data to avoid
|
||||
* recalculating it for each call to new().
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getByteOrder()
|
||||
{
|
||||
if (!isset(self::$_byte_order)) {
|
||||
// Check if "pack" gives the required IEEE 64bit float
|
||||
$teststr = pack("d", 1.2345);
|
||||
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
|
||||
if ($number == $teststr) {
|
||||
$byte_order = 0; // Little Endian
|
||||
} elseif ($number == strrev($teststr)){
|
||||
$byte_order = 1; // Big Endian
|
||||
} else {
|
||||
// Give up. I'll fix this in a later version.
|
||||
throw new PHPExcel_Writer_Exception("Required floating point format not supported on this platform.");
|
||||
}
|
||||
self::$_byte_order = $byte_order;
|
||||
}
|
||||
|
||||
return self::$_byte_order;
|
||||
}
|
||||
|
||||
/**
|
||||
* General storage function
|
||||
*
|
||||
* @param string $data binary data to append
|
||||
* @access private
|
||||
*/
|
||||
function _append($data)
|
||||
{
|
||||
if (strlen($data) - 4 > $this->_limit) {
|
||||
$data = $this->_addContinue($data);
|
||||
}
|
||||
$this->_data .= $data;
|
||||
$this->_datasize += strlen($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* General storage function like _append, but returns string instead of modifying $this->_data
|
||||
*
|
||||
* @param string $data binary data to write
|
||||
* @return string
|
||||
*/
|
||||
public function writeData($data)
|
||||
{
|
||||
if (strlen($data) - 4 > $this->_limit) {
|
||||
$data = $this->_addContinue($data);
|
||||
}
|
||||
$this->_datasize += strlen($data);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Excel BOF record to indicate the beginning of a stream or
|
||||
* sub-stream in the BIFF file.
|
||||
*
|
||||
* @param integer $type Type of BIFF file to write: 0x0005 Workbook,
|
||||
* 0x0010 Worksheet.
|
||||
* @access private
|
||||
*/
|
||||
function _storeBof($type)
|
||||
{
|
||||
$record = 0x0809; // Record identifier (BIFF5-BIFF8)
|
||||
$length = 0x0010;
|
||||
|
||||
// by inspection of real files, MS Office Excel 2007 writes the following
|
||||
$unknown = pack("VV", 0x000100D1, 0x00000406);
|
||||
|
||||
$build = 0x0DBB; // Excel 97
|
||||
$year = 0x07CC; // Excel 97
|
||||
|
||||
$version = 0x0600; // BIFF8
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvvv", $version, $type, $build, $year);
|
||||
$this->_append($header . $data . $unknown);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Excel EOF record to indicate the end of a BIFF stream.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _storeEof()
|
||||
{
|
||||
$record = 0x000A; // Record identifier
|
||||
$length = 0x0000; // Number of bytes to follow
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$this->_append($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Excel EOF record to indicate the end of a BIFF stream.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
public function writeEof()
|
||||
{
|
||||
$record = 0x000A; // Record identifier
|
||||
$length = 0x0000; // Number of bytes to follow
|
||||
$header = pack("vv", $record, $length);
|
||||
return $this->writeData($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* must be split up into CONTINUE blocks.
|
||||
*
|
||||
* This function takes a long BIFF record and inserts CONTINUE records as
|
||||
* necessary.
|
||||
*
|
||||
* @param string $data The original binary data to be written
|
||||
* @return string A very convenient string of continue blocks
|
||||
* @access private
|
||||
*/
|
||||
function _addContinue($data)
|
||||
{
|
||||
$limit = $this->_limit;
|
||||
$record = 0x003C; // Record identifier
|
||||
|
||||
// The first 2080/8224 bytes remain intact. However, we have to change
|
||||
// the length field of the record.
|
||||
$tmp = substr($data, 0, 2) . pack("v", $limit) . substr($data, 4, $limit);
|
||||
|
||||
$header = pack("vv", $record, $limit); // Headers for continue records
|
||||
|
||||
// Retrieve chunks of 2080/8224 bytes +4 for the header.
|
||||
$data_length = strlen($data);
|
||||
for ($i = $limit + 4; $i < ($data_length - $limit); $i += $limit) {
|
||||
$tmp .= $header;
|
||||
$tmp .= substr($data, $i, $limit);
|
||||
}
|
||||
|
||||
// Retrieve the last chunk of data
|
||||
$header = pack("vv", $record, strlen($data) - $i);
|
||||
$tmp .= $header;
|
||||
$tmp .= substr($data, $i, strlen($data) - $i);
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
}
|
537
extend/phpexcel/PHPExcel/Writer/Excel5/Escher.php
Executable file
537
extend/phpexcel/PHPExcel/Writer/Excel5/Escher.php
Executable file
@ -0,0 +1,537 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Shared_Escher_DggContainer_BstoreContainer
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel5_Escher
|
||||
{
|
||||
/**
|
||||
* The object we are writing
|
||||
*/
|
||||
private $_object;
|
||||
|
||||
/**
|
||||
* The written binary data
|
||||
*/
|
||||
private $_data;
|
||||
|
||||
/**
|
||||
* Shape offsets. Positions in binary stream where a new shape record begins
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_spOffsets;
|
||||
|
||||
/**
|
||||
* Shape types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_spTypes;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param mixed
|
||||
*/
|
||||
public function __construct($object)
|
||||
{
|
||||
$this->_object = $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the object to be written
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
// initialize
|
||||
$this->_data = '';
|
||||
|
||||
switch (get_class($this->_object)) {
|
||||
|
||||
case 'PHPExcel_Shared_Escher':
|
||||
if ($dggContainer = $this->_object->getDggContainer()) {
|
||||
$writer = new PHPExcel_Writer_Excel5_Escher($dggContainer);
|
||||
$this->_data = $writer->close();
|
||||
} else if ($dgContainer = $this->_object->getDgContainer()) {
|
||||
$writer = new PHPExcel_Writer_Excel5_Escher($dgContainer);
|
||||
$this->_data = $writer->close();
|
||||
$this->_spOffsets = $writer->getSpOffsets();
|
||||
$this->_spTypes = $writer->getSpTypes();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'PHPExcel_Shared_Escher_DggContainer':
|
||||
// this is a container record
|
||||
|
||||
// initialize
|
||||
$innerData = '';
|
||||
|
||||
// write the dgg
|
||||
$recVer = 0x0;
|
||||
$recInstance = 0x0000;
|
||||
$recType = 0xF006;
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
// dgg data
|
||||
$dggData =
|
||||
pack('VVVV'
|
||||
, $this->_object->getSpIdMax() // maximum shape identifier increased by one
|
||||
, $this->_object->getCDgSaved() + 1 // number of file identifier clusters increased by one
|
||||
, $this->_object->getCSpSaved()
|
||||
, $this->_object->getCDgSaved() // count total number of drawings saved
|
||||
);
|
||||
|
||||
// add file identifier clusters (one per drawing)
|
||||
$IDCLs = $this->_object->getIDCLs();
|
||||
|
||||
foreach ($IDCLs as $dgId => $maxReducedSpId) {
|
||||
$dggData .= pack('VV', $dgId, $maxReducedSpId + 1);
|
||||
}
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, strlen($dggData));
|
||||
$innerData .= $header . $dggData;
|
||||
|
||||
// write the bstoreContainer
|
||||
if ($bstoreContainer = $this->_object->getBstoreContainer()) {
|
||||
$writer = new PHPExcel_Writer_Excel5_Escher($bstoreContainer);
|
||||
$innerData .= $writer->close();
|
||||
}
|
||||
|
||||
// write the record
|
||||
$recVer = 0xF;
|
||||
$recInstance = 0x0000;
|
||||
$recType = 0xF000;
|
||||
$length = strlen($innerData);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
$this->_data = $header . $innerData;
|
||||
break;
|
||||
|
||||
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer':
|
||||
// this is a container record
|
||||
|
||||
// initialize
|
||||
$innerData = '';
|
||||
|
||||
// treat the inner data
|
||||
if ($BSECollection = $this->_object->getBSECollection()) {
|
||||
foreach ($BSECollection as $BSE) {
|
||||
$writer = new PHPExcel_Writer_Excel5_Escher($BSE);
|
||||
$innerData .= $writer->close();
|
||||
}
|
||||
}
|
||||
|
||||
// write the record
|
||||
$recVer = 0xF;
|
||||
$recInstance = count($this->_object->getBSECollection());
|
||||
$recType = 0xF001;
|
||||
$length = strlen($innerData);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
$this->_data = $header . $innerData;
|
||||
break;
|
||||
|
||||
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE':
|
||||
// this is a semi-container record
|
||||
|
||||
// initialize
|
||||
$innerData = '';
|
||||
|
||||
// here we treat the inner data
|
||||
if ($blip = $this->_object->getBlip()) {
|
||||
$writer = new PHPExcel_Writer_Excel5_Escher($blip);
|
||||
$innerData .= $writer->close();
|
||||
}
|
||||
|
||||
// initialize
|
||||
$data = '';
|
||||
|
||||
$btWin32 = $this->_object->getBlipType();
|
||||
$btMacOS = $this->_object->getBlipType();
|
||||
$data .= pack('CC', $btWin32, $btMacOS);
|
||||
|
||||
$rgbUid = pack('VVVV', 0,0,0,0); // todo
|
||||
$data .= $rgbUid;
|
||||
|
||||
$tag = 0;
|
||||
$size = strlen($innerData);
|
||||
$cRef = 1;
|
||||
$foDelay = 0; //todo
|
||||
$unused1 = 0x0;
|
||||
$cbName = 0x0;
|
||||
$unused2 = 0x0;
|
||||
$unused3 = 0x0;
|
||||
$data .= pack('vVVVCCCC', $tag, $size, $cRef, $foDelay, $unused1, $cbName, $unused2, $unused3);
|
||||
|
||||
$data .= $innerData;
|
||||
|
||||
// write the record
|
||||
$recVer = 0x2;
|
||||
$recInstance = $this->_object->getBlipType();
|
||||
$recType = 0xF007;
|
||||
$length = strlen($data);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
$this->_data = $header;
|
||||
|
||||
$this->_data .= $data;
|
||||
break;
|
||||
|
||||
case 'PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip':
|
||||
// this is an atom record
|
||||
|
||||
// write the record
|
||||
switch ($this->_object->getParent()->getBlipType()) {
|
||||
|
||||
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_JPEG:
|
||||
// initialize
|
||||
$innerData = '';
|
||||
|
||||
$rgbUid1 = pack('VVVV', 0,0,0,0); // todo
|
||||
$innerData .= $rgbUid1;
|
||||
|
||||
$tag = 0xFF; // todo
|
||||
$innerData .= pack('C', $tag);
|
||||
|
||||
$innerData .= $this->_object->getData();
|
||||
|
||||
$recVer = 0x0;
|
||||
$recInstance = 0x46A;
|
||||
$recType = 0xF01D;
|
||||
$length = strlen($innerData);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
$this->_data = $header;
|
||||
|
||||
$this->_data .= $innerData;
|
||||
break;
|
||||
|
||||
case PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE::BLIPTYPE_PNG:
|
||||
// initialize
|
||||
$innerData = '';
|
||||
|
||||
$rgbUid1 = pack('VVVV', 0,0,0,0); // todo
|
||||
$innerData .= $rgbUid1;
|
||||
|
||||
$tag = 0xFF; // todo
|
||||
$innerData .= pack('C', $tag);
|
||||
|
||||
$innerData .= $this->_object->getData();
|
||||
|
||||
$recVer = 0x0;
|
||||
$recInstance = 0x6E0;
|
||||
$recType = 0xF01E;
|
||||
$length = strlen($innerData);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
$this->_data = $header;
|
||||
|
||||
$this->_data .= $innerData;
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'PHPExcel_Shared_Escher_DgContainer':
|
||||
// this is a container record
|
||||
|
||||
// initialize
|
||||
$innerData = '';
|
||||
|
||||
// write the dg
|
||||
$recVer = 0x0;
|
||||
$recInstance = $this->_object->getDgId();
|
||||
$recType = 0xF008;
|
||||
$length = 8;
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
// number of shapes in this drawing (including group shape)
|
||||
$countShapes = count($this->_object->getSpgrContainer()->getChildren());
|
||||
$innerData .= $header . pack('VV', $countShapes, $this->_object->getLastSpId());
|
||||
//$innerData .= $header . pack('VV', 0, 0);
|
||||
|
||||
// write the spgrContainer
|
||||
if ($spgrContainer = $this->_object->getSpgrContainer()) {
|
||||
$writer = new PHPExcel_Writer_Excel5_Escher($spgrContainer);
|
||||
$innerData .= $writer->close();
|
||||
|
||||
// get the shape offsets relative to the spgrContainer record
|
||||
$spOffsets = $writer->getSpOffsets();
|
||||
$spTypes = $writer->getSpTypes();
|
||||
|
||||
// save the shape offsets relative to dgContainer
|
||||
foreach ($spOffsets as & $spOffset) {
|
||||
$spOffset += 24; // add length of dgContainer header data (8 bytes) plus dg data (16 bytes)
|
||||
}
|
||||
|
||||
$this->_spOffsets = $spOffsets;
|
||||
$this->_spTypes = $spTypes;
|
||||
}
|
||||
|
||||
// write the record
|
||||
$recVer = 0xF;
|
||||
$recInstance = 0x0000;
|
||||
$recType = 0xF002;
|
||||
$length = strlen($innerData);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
$this->_data = $header . $innerData;
|
||||
break;
|
||||
|
||||
case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer':
|
||||
// this is a container record
|
||||
|
||||
// initialize
|
||||
$innerData = '';
|
||||
|
||||
// initialize spape offsets
|
||||
$totalSize = 8;
|
||||
$spOffsets = array();
|
||||
$spTypes = array();
|
||||
|
||||
// treat the inner data
|
||||
foreach ($this->_object->getChildren() as $spContainer) {
|
||||
$writer = new PHPExcel_Writer_Excel5_Escher($spContainer);
|
||||
$spData = $writer->close();
|
||||
$innerData .= $spData;
|
||||
|
||||
// save the shape offsets (where new shape records begin)
|
||||
$totalSize += strlen($spData);
|
||||
$spOffsets[] = $totalSize;
|
||||
|
||||
$spTypes = array_merge($spTypes, $writer->getSpTypes());
|
||||
}
|
||||
|
||||
// write the record
|
||||
$recVer = 0xF;
|
||||
$recInstance = 0x0000;
|
||||
$recType = 0xF003;
|
||||
$length = strlen($innerData);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
$this->_data = $header . $innerData;
|
||||
$this->_spOffsets = $spOffsets;
|
||||
$this->_spTypes = $spTypes;
|
||||
break;
|
||||
|
||||
case 'PHPExcel_Shared_Escher_DgContainer_SpgrContainer_SpContainer':
|
||||
// initialize
|
||||
$data = '';
|
||||
|
||||
// build the data
|
||||
|
||||
// write group shape record, if necessary?
|
||||
if ($this->_object->getSpgr()) {
|
||||
$recVer = 0x1;
|
||||
$recInstance = 0x0000;
|
||||
$recType = 0xF009;
|
||||
$length = 0x00000010;
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
$data .= $header . pack('VVVV', 0,0,0,0);
|
||||
}
|
||||
$this->_spTypes[] = ($this->_object->getSpType());
|
||||
|
||||
// write the shape record
|
||||
$recVer = 0x2;
|
||||
$recInstance = $this->_object->getSpType(); // shape type
|
||||
$recType = 0xF00A;
|
||||
$length = 0x00000008;
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
$data .= $header . pack('VV', $this->_object->getSpId(), $this->_object->getSpgr() ? 0x0005 : 0x0A00);
|
||||
|
||||
|
||||
// the options
|
||||
if ($this->_object->getOPTCollection()) {
|
||||
$optData = '';
|
||||
|
||||
$recVer = 0x3;
|
||||
$recInstance = count($this->_object->getOPTCollection());
|
||||
$recType = 0xF00B;
|
||||
foreach ($this->_object->getOPTCollection() as $property => $value) {
|
||||
$optData .= pack('vV', $property, $value);
|
||||
}
|
||||
$length = strlen($optData);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
$data .= $header . $optData;
|
||||
}
|
||||
|
||||
// the client anchor
|
||||
if ($this->_object->getStartCoordinates()) {
|
||||
$clientAnchorData = '';
|
||||
|
||||
$recVer = 0x0;
|
||||
$recInstance = 0x0;
|
||||
$recType = 0xF010;
|
||||
|
||||
// start coordinates
|
||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($this->_object->getStartCoordinates());
|
||||
$c1 = PHPExcel_Cell::columnIndexFromString($column) - 1;
|
||||
$r1 = $row - 1;
|
||||
|
||||
// start offsetX
|
||||
$startOffsetX = $this->_object->getStartOffsetX();
|
||||
|
||||
// start offsetY
|
||||
$startOffsetY = $this->_object->getStartOffsetY();
|
||||
|
||||
// end coordinates
|
||||
list($column, $row) = PHPExcel_Cell::coordinateFromString($this->_object->getEndCoordinates());
|
||||
$c2 = PHPExcel_Cell::columnIndexFromString($column) - 1;
|
||||
$r2 = $row - 1;
|
||||
|
||||
// end offsetX
|
||||
$endOffsetX = $this->_object->getEndOffsetX();
|
||||
|
||||
// end offsetY
|
||||
$endOffsetY = $this->_object->getEndOffsetY();
|
||||
|
||||
$clientAnchorData = pack('vvvvvvvvv', $this->_object->getSpFlag(),
|
||||
$c1, $startOffsetX, $r1, $startOffsetY,
|
||||
$c2, $endOffsetX, $r2, $endOffsetY);
|
||||
|
||||
$length = strlen($clientAnchorData);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
$data .= $header . $clientAnchorData;
|
||||
}
|
||||
|
||||
// the client data, just empty for now
|
||||
if (!$this->_object->getSpgr()) {
|
||||
$clientDataData = '';
|
||||
|
||||
$recVer = 0x0;
|
||||
$recInstance = 0x0;
|
||||
$recType = 0xF011;
|
||||
|
||||
$length = strlen($clientDataData);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
$data .= $header . $clientDataData;
|
||||
}
|
||||
|
||||
// write the record
|
||||
$recVer = 0xF;
|
||||
$recInstance = 0x0000;
|
||||
$recType = 0xF004;
|
||||
$length = strlen($data);
|
||||
|
||||
$recVerInstance = $recVer;
|
||||
$recVerInstance |= $recInstance << 4;
|
||||
|
||||
$header = pack('vvV', $recVerInstance, $recType, $length);
|
||||
|
||||
$this->_data = $header . $data;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shape offsets
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSpOffsets()
|
||||
{
|
||||
return $this->_spOffsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the shape types
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSpTypes()
|
||||
{
|
||||
return $this->_spTypes;
|
||||
}
|
||||
|
||||
|
||||
}
|
165
extend/phpexcel/PHPExcel/Writer/Excel5/Font.php
Executable file
165
extend/phpexcel/PHPExcel/Writer/Excel5/Font.php
Executable file
@ -0,0 +1,165 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel5_Font
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel5_Font
|
||||
{
|
||||
/**
|
||||
* Color index
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_colorIndex;
|
||||
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var PHPExcel_Style_Font
|
||||
*/
|
||||
private $_font;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param PHPExcel_Style_Font $font
|
||||
*/
|
||||
public function __construct(PHPExcel_Style_Font $font = null)
|
||||
{
|
||||
$this->_colorIndex = 0x7FFF;
|
||||
$this->_font = $font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color index
|
||||
*
|
||||
* @param int $colorIndex
|
||||
*/
|
||||
public function setColorIndex($colorIndex)
|
||||
{
|
||||
$this->_colorIndex = $colorIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font record data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function writeFont()
|
||||
{
|
||||
$font_outline = 0;
|
||||
$font_shadow = 0;
|
||||
|
||||
$icv = $this->_colorIndex; // Index to color palette
|
||||
if ($this->_font->getSuperScript()) {
|
||||
$sss = 1;
|
||||
} else if ($this->_font->getSubScript()) {
|
||||
$sss = 2;
|
||||
} else {
|
||||
$sss = 0;
|
||||
}
|
||||
$bFamily = 0; // Font family
|
||||
$bCharSet = PHPExcel_Shared_Font::getCharsetFromFontName($this->_font->getName()); // Character set
|
||||
|
||||
$record = 0x31; // Record identifier
|
||||
$reserved = 0x00; // Reserved
|
||||
$grbit = 0x00; // Font attributes
|
||||
if ($this->_font->getItalic()) {
|
||||
$grbit |= 0x02;
|
||||
}
|
||||
if ($this->_font->getStrikethrough()) {
|
||||
$grbit |= 0x08;
|
||||
}
|
||||
if ($font_outline) {
|
||||
$grbit |= 0x10;
|
||||
}
|
||||
if ($font_shadow) {
|
||||
$grbit |= 0x20;
|
||||
}
|
||||
|
||||
$data = pack("vvvvvCCCC",
|
||||
$this->_font->getSize() * 20, // Fontsize (in twips)
|
||||
$grbit,
|
||||
$icv, // Colour
|
||||
self::_mapBold($this->_font->getBold()), // Font weight
|
||||
$sss, // Superscript/Subscript
|
||||
self::_mapUnderline($this->_font->getUnderline()),
|
||||
$bFamily,
|
||||
$bCharSet,
|
||||
$reserved
|
||||
);
|
||||
$data .= PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort($this->_font->getName());
|
||||
|
||||
$length = strlen($data);
|
||||
$header = pack("vv", $record, $length);
|
||||
|
||||
return($header . $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map to BIFF5-BIFF8 codes for bold
|
||||
*
|
||||
* @param boolean $bold
|
||||
* @return int
|
||||
*/
|
||||
private static function _mapBold($bold) {
|
||||
if ($bold) {
|
||||
return 0x2BC; // 700 = Bold font weight
|
||||
}
|
||||
return 0x190; // 400 = Normal font weight
|
||||
}
|
||||
|
||||
/**
|
||||
* Map of BIFF2-BIFF8 codes for underline styles
|
||||
* @static array of int
|
||||
*
|
||||
*/
|
||||
private static $_mapUnderline = array( PHPExcel_Style_Font::UNDERLINE_NONE => 0x00,
|
||||
PHPExcel_Style_Font::UNDERLINE_SINGLE => 0x01,
|
||||
PHPExcel_Style_Font::UNDERLINE_DOUBLE => 0x02,
|
||||
PHPExcel_Style_Font::UNDERLINE_SINGLEACCOUNTING => 0x21,
|
||||
PHPExcel_Style_Font::UNDERLINE_DOUBLEACCOUNTING => 0x22,
|
||||
);
|
||||
/**
|
||||
* Map underline
|
||||
*
|
||||
* @param string
|
||||
* @return int
|
||||
*/
|
||||
private static function _mapUnderline($underline) {
|
||||
if (isset(self::$_mapUnderline[$underline]))
|
||||
return self::$_mapUnderline[$underline];
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
}
|
1582
extend/phpexcel/PHPExcel/Writer/Excel5/Parser.php
Executable file
1582
extend/phpexcel/PHPExcel/Writer/Excel5/Parser.php
Executable file
File diff suppressed because it is too large
Load Diff
1450
extend/phpexcel/PHPExcel/Writer/Excel5/Workbook.php
Executable file
1450
extend/phpexcel/PHPExcel/Writer/Excel5/Workbook.php
Executable file
File diff suppressed because it is too large
Load Diff
3681
extend/phpexcel/PHPExcel/Writer/Excel5/Worksheet.php
Executable file
3681
extend/phpexcel/PHPExcel/Writer/Excel5/Worksheet.php
Executable file
File diff suppressed because it is too large
Load Diff
547
extend/phpexcel/PHPExcel/Writer/Excel5/Xf.php
Executable file
547
extend/phpexcel/PHPExcel/Writer/Excel5/Xf.php
Executable file
@ -0,0 +1,547 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
// Original file header of PEAR::Spreadsheet_Excel_Writer_Format (used as the base for this class):
|
||||
// -----------------------------------------------------------------------------------------
|
||||
// /*
|
||||
// * Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
|
||||
// *
|
||||
// * The majority of this is _NOT_ my code. I simply ported it from the
|
||||
// * PERL Spreadsheet::WriteExcel module.
|
||||
// *
|
||||
// * The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
// * <jmcnamara@cpan.org>
|
||||
// *
|
||||
// * I _DO_ maintain this code, and John McNamara has nothing to do with the
|
||||
// * porting of this code to PHP. Any questions directly related to this
|
||||
// * class library should be directed to me.
|
||||
// *
|
||||
// * License Information:
|
||||
// *
|
||||
// * Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
// * Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
|
||||
// *
|
||||
// * This library is free software; you can redistribute it and/or
|
||||
// * modify it under the terms of the GNU Lesser General Public
|
||||
// * License as published by the Free Software Foundation; either
|
||||
// * version 2.1 of the License, or (at your option) any later version.
|
||||
// *
|
||||
// * This library is distributed in the hope that it will be useful,
|
||||
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// * Lesser General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU Lesser General Public
|
||||
// * License along with this library; if not, write to the Free Software
|
||||
// * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
// */
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Excel5_Xf
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_Excel5
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Excel5_Xf
|
||||
{
|
||||
/**
|
||||
* Style XF or a cell XF ?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $_isStyleXf;
|
||||
|
||||
/**
|
||||
* Index to the FONT record. Index 4 does not exist
|
||||
* @var integer
|
||||
*/
|
||||
private $_fontIndex;
|
||||
|
||||
/**
|
||||
* An index (2 bytes) to a FORMAT record (number format).
|
||||
* @var integer
|
||||
*/
|
||||
public $_numberFormatIndex;
|
||||
|
||||
/**
|
||||
* 1 bit, apparently not used.
|
||||
* @var integer
|
||||
*/
|
||||
public $_text_justlast;
|
||||
|
||||
/**
|
||||
* The cell's foreground color.
|
||||
* @var integer
|
||||
*/
|
||||
public $_fg_color;
|
||||
|
||||
/**
|
||||
* The cell's background color.
|
||||
* @var integer
|
||||
*/
|
||||
public $_bg_color;
|
||||
|
||||
/**
|
||||
* Color of the bottom border of the cell.
|
||||
* @var integer
|
||||
*/
|
||||
public $_bottom_color;
|
||||
|
||||
/**
|
||||
* Color of the top border of the cell.
|
||||
* @var integer
|
||||
*/
|
||||
public $_top_color;
|
||||
|
||||
/**
|
||||
* Color of the left border of the cell.
|
||||
* @var integer
|
||||
*/
|
||||
public $_left_color;
|
||||
|
||||
/**
|
||||
* Color of the right border of the cell.
|
||||
* @var integer
|
||||
*/
|
||||
public $_right_color;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param PHPExcel_Style The XF format
|
||||
*/
|
||||
public function __construct(PHPExcel_Style $style = null)
|
||||
{
|
||||
$this->_isStyleXf = false;
|
||||
$this->_fontIndex = 0;
|
||||
|
||||
$this->_numberFormatIndex = 0;
|
||||
|
||||
$this->_text_justlast = 0;
|
||||
|
||||
$this->_fg_color = 0x40;
|
||||
$this->_bg_color = 0x41;
|
||||
|
||||
$this->_diag = 0;
|
||||
|
||||
$this->_bottom_color = 0x40;
|
||||
$this->_top_color = 0x40;
|
||||
$this->_left_color = 0x40;
|
||||
$this->_right_color = 0x40;
|
||||
$this->_diag_color = 0x40;
|
||||
$this->_style = $style;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate an Excel BIFF XF record (style or cell).
|
||||
*
|
||||
* @return string The XF record
|
||||
*/
|
||||
function writeXf()
|
||||
{
|
||||
// Set the type of the XF record and some of the attributes.
|
||||
if ($this->_isStyleXf) {
|
||||
$style = 0xFFF5;
|
||||
} else {
|
||||
$style = self::_mapLocked($this->_style->getProtection()->getLocked());
|
||||
$style |= self::_mapHidden($this->_style->getProtection()->getHidden()) << 1;
|
||||
}
|
||||
|
||||
// Flags to indicate if attributes have been set.
|
||||
$atr_num = ($this->_numberFormatIndex != 0)?1:0;
|
||||
$atr_fnt = ($this->_fontIndex != 0)?1:0;
|
||||
$atr_alc = ((int) $this->_style->getAlignment()->getWrapText()) ? 1 : 0;
|
||||
$atr_bdr = (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) ||
|
||||
self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) ||
|
||||
self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) ||
|
||||
self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0;
|
||||
$atr_pat = (($this->_fg_color != 0x40) ||
|
||||
($this->_bg_color != 0x41) ||
|
||||
self::_mapFillType($this->_style->getFill()->getFillType()))?1:0;
|
||||
$atr_prot = self::_mapLocked($this->_style->getProtection()->getLocked())
|
||||
| self::_mapHidden($this->_style->getProtection()->getHidden());
|
||||
|
||||
// Zero the default border colour if the border has not been set.
|
||||
if (self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
|
||||
$this->_bottom_color = 0;
|
||||
}
|
||||
if (self::_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) {
|
||||
$this->_top_color = 0;
|
||||
}
|
||||
if (self::_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
|
||||
$this->_right_color = 0;
|
||||
}
|
||||
if (self::_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
|
||||
$this->_left_color = 0;
|
||||
}
|
||||
if (self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
|
||||
$this->_diag_color = 0;
|
||||
}
|
||||
|
||||
$record = 0x00E0; // Record identifier
|
||||
$length = 0x0014; // Number of bytes to follow
|
||||
|
||||
$ifnt = $this->_fontIndex; // Index to FONT record
|
||||
$ifmt = $this->_numberFormatIndex; // Index to FORMAT record
|
||||
|
||||
$align = $this->_mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment
|
||||
$align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
|
||||
$align |= self::_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
|
||||
$align |= $this->_text_justlast << 7;
|
||||
|
||||
$used_attrib = $atr_num << 2;
|
||||
$used_attrib |= $atr_fnt << 3;
|
||||
$used_attrib |= $atr_alc << 4;
|
||||
$used_attrib |= $atr_bdr << 5;
|
||||
$used_attrib |= $atr_pat << 6;
|
||||
$used_attrib |= $atr_prot << 7;
|
||||
|
||||
$icv = $this->_fg_color; // fg and bg pattern colors
|
||||
$icv |= $this->_bg_color << 7;
|
||||
|
||||
$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()->getTop()->getBorderStyle()) << 8;
|
||||
$border1 |= self::_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
|
||||
$border1 |= $this->_left_color << 16;
|
||||
$border1 |= $this->_right_color << 23;
|
||||
|
||||
$diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
|
||||
$diag_tl_to_rb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|
||||
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_DOWN;
|
||||
$diag_tr_to_lb = $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_BOTH
|
||||
|| $diagonalDirection == PHPExcel_Style_Borders::DIAGONAL_UP;
|
||||
$border1 |= $diag_tl_to_rb << 30;
|
||||
$border1 |= $diag_tr_to_lb << 31;
|
||||
|
||||
$border2 = $this->_top_color; // Border color
|
||||
$border2 |= $this->_bottom_color << 7;
|
||||
$border2 |= $this->_diag_color << 14;
|
||||
$border2 |= self::_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
|
||||
$border2 |= self::_mapFillType($this->_style->getFill()->getFillType()) << 26;
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
|
||||
//BIFF8 options: identation, shrinkToFit and text direction
|
||||
$biff8_options = $this->_style->getAlignment()->getIndent();
|
||||
$biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
|
||||
|
||||
$data = pack("vvvC", $ifnt, $ifmt, $style, $align);
|
||||
$data .= pack("CCC"
|
||||
, self::_mapTextRotation($this->_style->getAlignment()->getTextRotation())
|
||||
, $biff8_options
|
||||
, $used_attrib
|
||||
);
|
||||
$data .= pack("VVv", $border1, $border2, $icv);
|
||||
|
||||
return($header . $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a style XF ?
|
||||
*
|
||||
* @param boolean $value
|
||||
*/
|
||||
public function setIsStyleXf($value)
|
||||
{
|
||||
$this->_isStyleXf = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cell's bottom border color
|
||||
*
|
||||
* @access public
|
||||
* @param int $colorIndex Color index
|
||||
*/
|
||||
function setBottomColor($colorIndex)
|
||||
{
|
||||
$this->_bottom_color = $colorIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cell's top border color
|
||||
*
|
||||
* @access public
|
||||
* @param int $colorIndex Color index
|
||||
*/
|
||||
function setTopColor($colorIndex)
|
||||
{
|
||||
$this->_top_color = $colorIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cell's left border color
|
||||
*
|
||||
* @access public
|
||||
* @param int $colorIndex Color index
|
||||
*/
|
||||
function setLeftColor($colorIndex)
|
||||
{
|
||||
$this->_left_color = $colorIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cell's right border color
|
||||
*
|
||||
* @access public
|
||||
* @param int $colorIndex Color index
|
||||
*/
|
||||
function setRightColor($colorIndex)
|
||||
{
|
||||
$this->_right_color = $colorIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cell's diagonal border color
|
||||
*
|
||||
* @access public
|
||||
* @param int $colorIndex Color index
|
||||
*/
|
||||
function setDiagColor($colorIndex)
|
||||
{
|
||||
$this->_diag_color = $colorIndex;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the cell's foreground color
|
||||
*
|
||||
* @access public
|
||||
* @param int $colorIndex Color index
|
||||
*/
|
||||
function setFgColor($colorIndex)
|
||||
{
|
||||
$this->_fg_color = $colorIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cell's background color
|
||||
*
|
||||
* @access public
|
||||
* @param int $colorIndex Color index
|
||||
*/
|
||||
function setBgColor($colorIndex)
|
||||
{
|
||||
$this->_bg_color = $colorIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the index to the number format record
|
||||
* It can be date, time, currency, etc...
|
||||
*
|
||||
* @access public
|
||||
* @param integer $numberFormatIndex Index to format record
|
||||
*/
|
||||
function setNumberFormatIndex($numberFormatIndex)
|
||||
{
|
||||
$this->_numberFormatIndex = $numberFormatIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font index.
|
||||
*
|
||||
* @param int $value Font index, note that value 4 does not exist
|
||||
*/
|
||||
public function setFontIndex($value)
|
||||
{
|
||||
$this->_fontIndex = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map of BIFF2-BIFF8 codes for border styles
|
||||
* @static array of int
|
||||
*
|
||||
*/
|
||||
private static $_mapBorderStyle = array ( PHPExcel_Style_Border::BORDER_NONE => 0x00,
|
||||
PHPExcel_Style_Border::BORDER_THIN => 0x01,
|
||||
PHPExcel_Style_Border::BORDER_MEDIUM => 0x02,
|
||||
PHPExcel_Style_Border::BORDER_DASHED => 0x03,
|
||||
PHPExcel_Style_Border::BORDER_DOTTED => 0x04,
|
||||
PHPExcel_Style_Border::BORDER_THICK => 0x05,
|
||||
PHPExcel_Style_Border::BORDER_DOUBLE => 0x06,
|
||||
PHPExcel_Style_Border::BORDER_HAIR => 0x07,
|
||||
PHPExcel_Style_Border::BORDER_MEDIUMDASHED => 0x08,
|
||||
PHPExcel_Style_Border::BORDER_DASHDOT => 0x09,
|
||||
PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT => 0x0A,
|
||||
PHPExcel_Style_Border::BORDER_DASHDOTDOT => 0x0B,
|
||||
PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT => 0x0C,
|
||||
PHPExcel_Style_Border::BORDER_SLANTDASHDOT => 0x0D,
|
||||
);
|
||||
|
||||
/**
|
||||
* Map border style
|
||||
*
|
||||
* @param string $borderStyle
|
||||
* @return int
|
||||
*/
|
||||
private static function _mapBorderStyle($borderStyle) {
|
||||
if (isset(self::$_mapBorderStyle[$borderStyle]))
|
||||
return self::$_mapBorderStyle[$borderStyle];
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map of BIFF2-BIFF8 codes for fill types
|
||||
* @static array of int
|
||||
*
|
||||
*/
|
||||
private static $_mapFillType = array( PHPExcel_Style_Fill::FILL_NONE => 0x00,
|
||||
PHPExcel_Style_Fill::FILL_SOLID => 0x01,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_MEDIUMGRAY => 0x02,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKGRAY => 0x03,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRAY => 0x04,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKHORIZONTAL => 0x05,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKVERTICAL => 0x06,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKDOWN => 0x07,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKUP => 0x08,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKGRID => 0x09,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_DARKTRELLIS => 0x0A,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTHORIZONTAL => 0x0B,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTVERTICAL => 0x0C,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTDOWN => 0x0D,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTUP => 0x0E,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTGRID => 0x0F,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_GRAY125 => 0x11,
|
||||
PHPExcel_Style_Fill::FILL_PATTERN_GRAY0625 => 0x12,
|
||||
PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8
|
||||
PHPExcel_Style_Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8
|
||||
);
|
||||
/**
|
||||
* Map fill type
|
||||
*
|
||||
* @param string $fillType
|
||||
* @return int
|
||||
*/
|
||||
private static function _mapFillType($fillType) {
|
||||
if (isset(self::$_mapFillType[$fillType]))
|
||||
return self::$_mapFillType[$fillType];
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map of BIFF2-BIFF8 codes for horizontal alignment
|
||||
* @static array of int
|
||||
*
|
||||
*/
|
||||
private static $_mapHAlign = array( PHPExcel_Style_Alignment::HORIZONTAL_GENERAL => 0,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_LEFT => 1,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_CENTER => 2,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_RIGHT => 3,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_FILL => 4,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY => 5,
|
||||
PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS => 6,
|
||||
);
|
||||
/**
|
||||
* Map to BIFF2-BIFF8 codes for horizontal alignment
|
||||
*
|
||||
* @param string $hAlign
|
||||
* @return int
|
||||
*/
|
||||
private function _mapHAlign($hAlign)
|
||||
{
|
||||
if (isset(self::$_mapHAlign[$hAlign]))
|
||||
return self::$_mapHAlign[$hAlign];
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map of BIFF2-BIFF8 codes for vertical alignment
|
||||
* @static array of int
|
||||
*
|
||||
*/
|
||||
private static $_mapVAlign = array( PHPExcel_Style_Alignment::VERTICAL_TOP => 0,
|
||||
PHPExcel_Style_Alignment::VERTICAL_CENTER => 1,
|
||||
PHPExcel_Style_Alignment::VERTICAL_BOTTOM => 2,
|
||||
PHPExcel_Style_Alignment::VERTICAL_JUSTIFY => 3,
|
||||
);
|
||||
/**
|
||||
* Map to BIFF2-BIFF8 codes for vertical alignment
|
||||
*
|
||||
* @param string $vAlign
|
||||
* @return int
|
||||
*/
|
||||
private static function _mapVAlign($vAlign) {
|
||||
if (isset(self::$_mapVAlign[$vAlign]))
|
||||
return self::$_mapVAlign[$vAlign];
|
||||
return 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map to BIFF8 codes for text rotation angle
|
||||
*
|
||||
* @param int $textRotation
|
||||
* @return int
|
||||
*/
|
||||
private static function _mapTextRotation($textRotation) {
|
||||
if ($textRotation >= 0) {
|
||||
return $textRotation;
|
||||
}
|
||||
if ($textRotation == -165) {
|
||||
return 255;
|
||||
}
|
||||
if ($textRotation < 0) {
|
||||
return 90 - $textRotation;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map locked
|
||||
*
|
||||
* @param string
|
||||
* @return int
|
||||
*/
|
||||
private static function _mapLocked($locked) {
|
||||
switch ($locked) {
|
||||
case PHPExcel_Style_Protection::PROTECTION_INHERIT: return 1;
|
||||
case PHPExcel_Style_Protection::PROTECTION_PROTECTED: return 1;
|
||||
case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED: return 0;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map hidden
|
||||
*
|
||||
* @param string
|
||||
* @return int
|
||||
*/
|
||||
private static function _mapHidden($hidden) {
|
||||
switch ($hidden) {
|
||||
case PHPExcel_Style_Protection::PROTECTION_INHERIT: return 0;
|
||||
case PHPExcel_Style_Protection::PROTECTION_PROTECTED: return 1;
|
||||
case PHPExcel_Style_Protection::PROTECTION_UNPROTECTED: return 0;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
52
extend/phpexcel/PHPExcel/Writer/Exception.php
Executable file
52
extend/phpexcel/PHPExcel/Writer/Exception.php
Executable file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_Exception
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_Exception extends PHPExcel_Exception {
|
||||
/**
|
||||
* Error handler callback
|
||||
*
|
||||
* @param mixed $code
|
||||
* @param mixed $string
|
||||
* @param mixed $file
|
||||
* @param mixed $line
|
||||
* @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;
|
||||
}
|
||||
}
|
1532
extend/phpexcel/PHPExcel/Writer/HTML.php
Executable file
1532
extend/phpexcel/PHPExcel/Writer/HTML.php
Executable file
File diff suppressed because it is too large
Load Diff
46
extend/phpexcel/PHPExcel/Writer/IWriter.php
Executable file
46
extend/phpexcel/PHPExcel/Writer/IWriter.php
Executable file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_IWriter
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
interface PHPExcel_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Save PHPExcel to file
|
||||
*
|
||||
* @param string $pFilename Name of the file to save
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function save($pFilename = NULL);
|
||||
|
||||
}
|
90
extend/phpexcel/PHPExcel/Writer/PDF.php
Executable file
90
extend/phpexcel/PHPExcel/Writer/PDF.php
Executable file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_PDF
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_PDF
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_PDF
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_PDF
|
||||
{
|
||||
|
||||
/**
|
||||
* The wrapper for the requested PDF rendering engine
|
||||
*
|
||||
* @var PHPExcel_Writer_PDF_Core
|
||||
*/
|
||||
private $_renderer = NULL;
|
||||
|
||||
/**
|
||||
* Instantiate a new renderer of the configured type within this container class
|
||||
*
|
||||
* @param PHPExcel $phpExcel PHPExcel object
|
||||
* @throws PHPExcel_Writer_Exception when PDF library is not configured
|
||||
*/
|
||||
public function __construct(PHPExcel $phpExcel)
|
||||
{
|
||||
$pdfLibraryName = PHPExcel_Settings::getPdfRendererName();
|
||||
if (is_null($pdfLibraryName)) {
|
||||
throw new PHPExcel_Writer_Exception("PDF Rendering library has not been defined.");
|
||||
}
|
||||
|
||||
$pdfLibraryPath = PHPExcel_Settings::getPdfRendererPath();
|
||||
if (is_null($pdfLibraryName)) {
|
||||
throw new PHPExcel_Writer_Exception("PDF Rendering library path has not been defined.");
|
||||
}
|
||||
$includePath = str_replace('\\', '/', get_include_path());
|
||||
$rendererPath = str_replace('\\', '/', $pdfLibraryPath);
|
||||
if (strpos($rendererPath, $includePath) === false) {
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $pdfLibraryPath);
|
||||
}
|
||||
|
||||
$rendererName = 'PHPExcel_Writer_PDF_' . $pdfLibraryName;
|
||||
$this->_renderer = new $rendererName($phpExcel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Magic method to handle direct calls to the configured PDF renderer wrapper class.
|
||||
*
|
||||
* @param string $name Renderer library method name
|
||||
* @param mixed[] $arguments Array of arguments to pass to the renderer method
|
||||
* @return mixed Returned data from the PDF renderer wrapper method
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
{
|
||||
if ($this->_renderer === NULL) {
|
||||
throw new PHPExcel_Writer_Exception("PDF Rendering library has not been defined.");
|
||||
}
|
||||
|
||||
return call_user_func_array(array($this->_renderer, $name), $arguments);
|
||||
}
|
||||
|
||||
}
|
364
extend/phpexcel/PHPExcel/Writer/PDF/Core.php
Executable file
364
extend/phpexcel/PHPExcel/Writer/PDF/Core.php
Executable file
@ -0,0 +1,364 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_PDF
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_PDF_Core
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_PDF
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
abstract class PHPExcel_Writer_PDF_Core extends PHPExcel_Writer_HTML
|
||||
{
|
||||
/**
|
||||
* Temporary storage directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_tempDir = '';
|
||||
|
||||
/**
|
||||
* Font
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_font = 'freesans';
|
||||
|
||||
/**
|
||||
* Orientation (Over-ride)
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_orientation = NULL;
|
||||
|
||||
/**
|
||||
* Paper size (Over-ride)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_paperSize = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Temporary storage for Save Array Return type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_saveArrayReturnType;
|
||||
|
||||
/**
|
||||
* Paper Sizes xRef List
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $_paperSizes = array(
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER
|
||||
=> 'LETTER', // (8.5 in. by 11 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_SMALL
|
||||
=> 'LETTER', // (8.5 in. by 11 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_TABLOID
|
||||
=> array(792.00, 1224.00), // (11 in. by 17 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEDGER
|
||||
=> array(1224.00, 792.00), // (17 in. by 11 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEGAL
|
||||
=> 'LEGAL', // (8.5 in. by 14 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_STATEMENT
|
||||
=> array(396.00, 612.00), // (5.5 in. by 8.5 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_EXECUTIVE
|
||||
=> 'EXECUTIVE', // (7.25 in. by 10.5 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3
|
||||
=> 'A3', // (297 mm by 420 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4
|
||||
=> 'A4', // (210 mm by 297 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_SMALL
|
||||
=> 'A4', // (210 mm by 297 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A5
|
||||
=> 'A5', // (148 mm by 210 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_B4
|
||||
=> 'B4', // (250 mm by 353 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_B5
|
||||
=> 'B5', // (176 mm by 250 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_FOLIO
|
||||
=> 'FOLIO', // (8.5 in. by 13 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_QUARTO
|
||||
=> array(609.45, 779.53), // (215 mm by 275 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_1
|
||||
=> array(720.00, 1008.00), // (10 in. by 14 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_2
|
||||
=> array(792.00, 1224.00), // (11 in. by 17 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_NOTE
|
||||
=> 'LETTER', // (8.5 in. by 11 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO9_ENVELOPE
|
||||
=> array(279.00, 639.00), // (3.875 in. by 8.875 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO10_ENVELOPE
|
||||
=> array(297.00, 684.00), // (4.125 in. by 9.5 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO11_ENVELOPE
|
||||
=> array(324.00, 747.00), // (4.5 in. by 10.375 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO12_ENVELOPE
|
||||
=> array(342.00, 792.00), // (4.75 in. by 11 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_NO14_ENVELOPE
|
||||
=> array(360.00, 828.00), // (5 in. by 11.5 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_C
|
||||
=> array(1224.00, 1584.00), // (17 in. by 22 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_D
|
||||
=> array(1584.00, 2448.00), // (22 in. by 34 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_E
|
||||
=> array(2448.00, 3168.00), // (34 in. by 44 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_DL_ENVELOPE
|
||||
=> array(311.81, 623.62), // (110 mm by 220 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_C5_ENVELOPE
|
||||
=> 'C5', // (162 mm by 229 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_C3_ENVELOPE
|
||||
=> 'C3', // (324 mm by 458 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_C4_ENVELOPE
|
||||
=> 'C4', // (229 mm by 324 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_C6_ENVELOPE
|
||||
=> 'C6', // (114 mm by 162 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_C65_ENVELOPE
|
||||
=> array(323.15, 649.13), // (114 mm by 229 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_B4_ENVELOPE
|
||||
=> 'B4', // (250 mm by 353 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_B5_ENVELOPE
|
||||
=> 'B5', // (176 mm by 250 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_B6_ENVELOPE
|
||||
=> array(498.90, 354.33), // (176 mm by 125 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_ITALY_ENVELOPE
|
||||
=> array(311.81, 651.97), // (110 mm by 230 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_MONARCH_ENVELOPE
|
||||
=> array(279.00, 540.00), // (3.875 in. by 7.5 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_6_3_4_ENVELOPE
|
||||
=> array(261.00, 468.00), // (3.625 in. by 6.5 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_US_STANDARD_FANFOLD
|
||||
=> array(1071.00, 792.00), // (14.875 in. by 11 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_GERMAN_STANDARD_FANFOLD
|
||||
=> array(612.00, 864.00), // (8.5 in. by 12 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_GERMAN_LEGAL_FANFOLD
|
||||
=> 'FOLIO', // (8.5 in. by 13 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_ISO_B4
|
||||
=> 'B4', // (250 mm by 353 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_JAPANESE_DOUBLE_POSTCARD
|
||||
=> array(566.93, 419.53), // (200 mm by 148 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_PAPER_1
|
||||
=> array(648.00, 792.00), // (9 in. by 11 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_PAPER_2
|
||||
=> array(720.00, 792.00), // (10 in. by 11 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_STANDARD_PAPER_3
|
||||
=> array(1080.00, 792.00), // (15 in. by 11 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_INVITE_ENVELOPE
|
||||
=> array(623.62, 623.62), // (220 mm by 220 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_EXTRA_PAPER
|
||||
=> array(667.80, 864.00), // (9.275 in. by 12 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LEGAL_EXTRA_PAPER
|
||||
=> array(667.80, 1080.00), // (9.275 in. by 15 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_TABLOID_EXTRA_PAPER
|
||||
=> array(841.68, 1296.00), // (11.69 in. by 18 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_EXTRA_PAPER
|
||||
=> array(668.98, 912.76), // (236 mm by 322 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_TRANSVERSE_PAPER
|
||||
=> array(595.80, 792.00), // (8.275 in. by 11 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_TRANSVERSE_PAPER
|
||||
=> 'A4', // (210 mm by 297 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER
|
||||
=> array(667.80, 864.00), // (9.275 in. by 12 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_SUPERA_SUPERA_A4_PAPER
|
||||
=> array(643.46, 1009.13), // (227 mm by 356 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_SUPERB_SUPERB_A3_PAPER
|
||||
=> array(864.57, 1380.47), // (305 mm by 487 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER_PLUS_PAPER
|
||||
=> array(612.00, 913.68), // (8.5 in. by 12.69 in.)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4_PLUS_PAPER
|
||||
=> array(595.28, 935.43), // (210 mm by 330 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A5_TRANSVERSE_PAPER
|
||||
=> 'A5', // (148 mm by 210 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_JIS_B5_TRANSVERSE_PAPER
|
||||
=> array(515.91, 728.50), // (182 mm by 257 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3_EXTRA_PAPER
|
||||
=> array(912.76, 1261.42), // (322 mm by 445 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A5_EXTRA_PAPER
|
||||
=> array(493.23, 666.14), // (174 mm by 235 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_ISO_B5_EXTRA_PAPER
|
||||
=> array(569.76, 782.36), // (201 mm by 276 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A2_PAPER
|
||||
=> 'A2', // (420 mm by 594 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3_TRANSVERSE_PAPER
|
||||
=> 'A3', // (297 mm by 420 mm)
|
||||
PHPExcel_Worksheet_PageSetup::PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER
|
||||
=> array(912.76, 1261.42) // (322 mm by 445 mm)
|
||||
);
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Writer_PDF
|
||||
*
|
||||
* @param PHPExcel $phpExcel PHPExcel object
|
||||
*/
|
||||
public function __construct(PHPExcel $phpExcel)
|
||||
{
|
||||
parent::__construct($phpExcel);
|
||||
$this->setUseInlineCss(TRUE);
|
||||
$this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Font
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFont()
|
||||
{
|
||||
return $this->_font;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set font. Examples:
|
||||
* 'arialunicid0-chinese-simplified'
|
||||
* 'arialunicid0-chinese-traditional'
|
||||
* 'arialunicid0-korean'
|
||||
* 'arialunicid0-japanese'
|
||||
*
|
||||
* @param string $fontName
|
||||
*/
|
||||
public function setFont($fontName)
|
||||
{
|
||||
$this->_font = $fontName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Paper Size
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPaperSize()
|
||||
{
|
||||
return $this->_paperSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Paper Size
|
||||
*
|
||||
* @param string $pValue Paper size
|
||||
* @return PHPExcel_Writer_PDF
|
||||
*/
|
||||
public function setPaperSize($pValue = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER)
|
||||
{
|
||||
$this->_paperSize = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Orientation
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOrientation()
|
||||
{
|
||||
return $this->_orientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Orientation
|
||||
*
|
||||
* @param string $pValue Page orientation
|
||||
* @return PHPExcel_Writer_PDF
|
||||
*/
|
||||
public function setOrientation($pValue = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT)
|
||||
{
|
||||
$this->_orientation = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get temporary storage directory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTempDir()
|
||||
{
|
||||
return $this->_tempDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set temporary storage directory
|
||||
*
|
||||
* @param string $pValue Temporary storage directory
|
||||
* @throws PHPExcel_Writer_Exception when directory does not exist
|
||||
* @return PHPExcel_Writer_PDF
|
||||
*/
|
||||
public function setTempDir($pValue = '')
|
||||
{
|
||||
if (is_dir($pValue)) {
|
||||
$this->_tempDir = $pValue;
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception("Directory does not exist: $pValue");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPExcel to PDF file, pre-save
|
||||
*
|
||||
* @param string $pFilename Name of the file to save as
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
protected function prepareForSave($pFilename = NULL)
|
||||
{
|
||||
// garbage collect
|
||||
$this->_phpExcel->garbageCollect();
|
||||
|
||||
$this->_saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
|
||||
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE);
|
||||
|
||||
// Open file
|
||||
$fileHandle = fopen($pFilename, 'w');
|
||||
if ($fileHandle === FALSE) {
|
||||
throw new PHPExcel_Writer_Exception("Could not open file $pFilename for writing.");
|
||||
}
|
||||
|
||||
// Set PDF
|
||||
$this->_isPdf = TRUE;
|
||||
// Build CSS
|
||||
$this->buildCSS(TRUE);
|
||||
|
||||
return $fileHandle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPExcel to PDF file, post-save
|
||||
*
|
||||
* @param resource $fileHandle
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
protected function restoreStateAfterSave($fileHandle)
|
||||
{
|
||||
// Close file
|
||||
fclose($fileHandle);
|
||||
|
||||
PHPExcel_Calculation::setArrayReturnType($this->_saveArrayReturnType);
|
||||
}
|
||||
|
||||
}
|
120
extend/phpexcel/PHPExcel/Writer/PDF/DomPDF.php
Executable file
120
extend/phpexcel/PHPExcel/Writer/PDF/DomPDF.php
Executable file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_PDF
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** Require DomPDF library */
|
||||
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/dompdf_config.inc.php';
|
||||
if (file_exists($pdfRendererClassFile)) {
|
||||
require_once $pdfRendererClassFile;
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_PDF_DomPDF
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_PDF
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_PDF_DomPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Create a new PHPExcel_Writer_PDF
|
||||
*
|
||||
* @param PHPExcel $phpExcel PHPExcel object
|
||||
*/
|
||||
public function __construct(PHPExcel $phpExcel)
|
||||
{
|
||||
parent::__construct($phpExcel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPExcel to file
|
||||
*
|
||||
* @param string $pFilename Name of the file to save as
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function save($pFilename = NULL)
|
||||
{
|
||||
$fileHandle = parent::prepareForSave($pFilename);
|
||||
|
||||
// Default PDF paper size
|
||||
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
|
||||
|
||||
// Check for paper size and page orientation
|
||||
if (is_null($this->getSheetIndex())) {
|
||||
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation()
|
||||
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
|
||||
? 'L'
|
||||
: 'P';
|
||||
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
|
||||
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
|
||||
} else {
|
||||
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
|
||||
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
|
||||
? 'L'
|
||||
: 'P';
|
||||
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
|
||||
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
|
||||
}
|
||||
|
||||
// Override Page Orientation
|
||||
if (!is_null($this->getOrientation())) {
|
||||
$orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT)
|
||||
? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT
|
||||
: $this->getOrientation();
|
||||
}
|
||||
// Override Paper Size
|
||||
if (!is_null($this->getPaperSize())) {
|
||||
$printPaperSize = $this->getPaperSize();
|
||||
}
|
||||
|
||||
if (isset(self::$_paperSizes[$printPaperSize])) {
|
||||
$paperSize = self::$_paperSizes[$printPaperSize];
|
||||
}
|
||||
|
||||
$orientation = ($orientation == 'L') ? 'landscape' : 'portrait';
|
||||
|
||||
// Create PDF
|
||||
$pdf = new DOMPDF();
|
||||
$pdf->set_paper(strtolower($paperSize), $orientation);
|
||||
|
||||
$pdf->load_html(
|
||||
$this->generateHTMLHeader(FALSE) .
|
||||
$this->generateSheetData() .
|
||||
$this->generateHTMLFooter()
|
||||
);
|
||||
$pdf->render();
|
||||
|
||||
// Write to file
|
||||
fwrite($fileHandle, $pdf->output());
|
||||
|
||||
parent::restoreStateAfterSave($fileHandle);
|
||||
}
|
||||
|
||||
}
|
130
extend/phpexcel/PHPExcel/Writer/PDF/mPDF.php
Executable file
130
extend/phpexcel/PHPExcel/Writer/PDF/mPDF.php
Executable file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_PDF
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** Require mPDF library */
|
||||
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/mpdf.php';
|
||||
if (file_exists($pdfRendererClassFile)) {
|
||||
require_once $pdfRendererClassFile;
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_PDF_mPDF
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_PDF
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_PDF_mPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Create a new PHPExcel_Writer_PDF
|
||||
*
|
||||
* @param PHPExcel $phpExcel PHPExcel object
|
||||
*/
|
||||
public function __construct(PHPExcel $phpExcel)
|
||||
{
|
||||
parent::__construct($phpExcel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPExcel to file
|
||||
*
|
||||
* @param string $pFilename Name of the file to save as
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function save($pFilename = NULL)
|
||||
{
|
||||
$fileHandle = parent::prepareForSave($pFilename);
|
||||
|
||||
// Default PDF paper size
|
||||
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
|
||||
|
||||
// Check for paper size and page orientation
|
||||
if (is_null($this->getSheetIndex())) {
|
||||
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation()
|
||||
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
|
||||
? 'L'
|
||||
: 'P';
|
||||
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
|
||||
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
|
||||
} else {
|
||||
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
|
||||
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
|
||||
? 'L'
|
||||
: 'P';
|
||||
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
|
||||
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
|
||||
}
|
||||
$this->setOrientation($orientation);
|
||||
|
||||
// Override Page Orientation
|
||||
if (!is_null($this->getOrientation())) {
|
||||
$orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT)
|
||||
? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT
|
||||
: $this->getOrientation();
|
||||
}
|
||||
$orientation = strtoupper($orientation);
|
||||
|
||||
// Override Paper Size
|
||||
if (!is_null($this->getPaperSize())) {
|
||||
$printPaperSize = $this->getPaperSize();
|
||||
}
|
||||
|
||||
if (isset(self::$_paperSizes[$printPaperSize])) {
|
||||
$paperSize = self::$_paperSizes[$printPaperSize];
|
||||
}
|
||||
|
||||
// Create PDF
|
||||
$pdf = new mpdf();
|
||||
$ortmp = $orientation;
|
||||
$pdf->_setPageSize(strtoupper($paperSize), $ortmp);
|
||||
$pdf->DefOrientation = $orientation;
|
||||
$pdf->AddPage($orientation);
|
||||
|
||||
// Document info
|
||||
$pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
|
||||
$pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
|
||||
$pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
|
||||
$pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
|
||||
$pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
|
||||
|
||||
$pdf->WriteHTML(
|
||||
$this->generateHTMLHeader(FALSE) .
|
||||
$this->generateSheetData() .
|
||||
$this->generateHTMLFooter()
|
||||
);
|
||||
|
||||
// Write to file
|
||||
fwrite($fileHandle, $pdf->Output('', 'S'));
|
||||
|
||||
parent::restoreStateAfterSave($fileHandle);
|
||||
}
|
||||
|
||||
}
|
136
extend/phpexcel/PHPExcel/Writer/PDF/tcPDF.php
Executable file
136
extend/phpexcel/PHPExcel/Writer/PDF/tcPDF.php
Executable file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPExcel
|
||||
*
|
||||
* Copyright (c) 2006 - 2014 PHPExcel
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_PDF
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
* @version 1.8.0, 2014-03-02
|
||||
*/
|
||||
|
||||
|
||||
/** Require tcPDF library */
|
||||
$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/tcpdf.php';
|
||||
if (file_exists($pdfRendererClassFile)) {
|
||||
$k_path_url = PHPExcel_Settings::getPdfRendererPath();
|
||||
require_once $pdfRendererClassFile;
|
||||
} else {
|
||||
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
|
||||
}
|
||||
|
||||
/**
|
||||
* PHPExcel_Writer_PDF_tcPDF
|
||||
*
|
||||
* @category PHPExcel
|
||||
* @package PHPExcel_Writer_PDF
|
||||
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||
*/
|
||||
class PHPExcel_Writer_PDF_tcPDF extends PHPExcel_Writer_PDF_Core implements PHPExcel_Writer_IWriter
|
||||
{
|
||||
/**
|
||||
* Create a new PHPExcel_Writer_PDF
|
||||
*
|
||||
* @param PHPExcel $phpExcel PHPExcel object
|
||||
*/
|
||||
public function __construct(PHPExcel $phpExcel)
|
||||
{
|
||||
parent::__construct($phpExcel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PHPExcel to file
|
||||
*
|
||||
* @param string $pFilename Name of the file to save as
|
||||
* @throws PHPExcel_Writer_Exception
|
||||
*/
|
||||
public function save($pFilename = NULL)
|
||||
{
|
||||
$fileHandle = parent::prepareForSave($pFilename);
|
||||
|
||||
// Default PDF paper size
|
||||
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
|
||||
|
||||
// Check for paper size and page orientation
|
||||
if (is_null($this->getSheetIndex())) {
|
||||
$orientation = ($this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation()
|
||||
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
|
||||
? 'L'
|
||||
: 'P';
|
||||
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
|
||||
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
|
||||
} else {
|
||||
$orientation = ($this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation()
|
||||
== PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
|
||||
? 'L'
|
||||
: 'P';
|
||||
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
|
||||
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
|
||||
}
|
||||
|
||||
// Override Page Orientation
|
||||
if (!is_null($this->getOrientation())) {
|
||||
$orientation = ($this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE)
|
||||
? 'L'
|
||||
: 'P';
|
||||
}
|
||||
// Override Paper Size
|
||||
if (!is_null($this->getPaperSize())) {
|
||||
$printPaperSize = $this->getPaperSize();
|
||||
}
|
||||
|
||||
if (isset(self::$_paperSizes[$printPaperSize])) {
|
||||
$paperSize = self::$_paperSizes[$printPaperSize];
|
||||
}
|
||||
|
||||
|
||||
// Create PDF
|
||||
$pdf = new TCPDF($orientation, 'pt', $paperSize);
|
||||
$pdf->setFontSubsetting(FALSE);
|
||||
// Set margins, converting inches to points (using 72 dpi)
|
||||
$pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72);
|
||||
$pdf->SetAutoPageBreak(TRUE, $printMargins->getBottom() * 72);
|
||||
|
||||
$pdf->setPrintHeader(FALSE);
|
||||
$pdf->setPrintFooter(FALSE);
|
||||
|
||||
$pdf->AddPage();
|
||||
|
||||
// Set the appropriate font
|
||||
$pdf->SetFont($this->getFont());
|
||||
$pdf->writeHTML(
|
||||
$this->generateHTMLHeader(FALSE) .
|
||||
$this->generateSheetData() .
|
||||
$this->generateHTMLFooter()
|
||||
);
|
||||
|
||||
// Document info
|
||||
$pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
|
||||
$pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
|
||||
$pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
|
||||
$pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
|
||||
$pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
|
||||
|
||||
// Write to file
|
||||
fwrite($fileHandle, $pdf->output($pFilename, 'S'));
|
||||
|
||||
parent::restoreStateAfterSave($fileHandle);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user