From 5508013569b122c71dce94bf2cab7add370bbd46 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Fri, 15 May 2015 13:17:40 +0200 Subject: [PATCH] PSR-2 : Fixes --- Classes/PHPExcel/Worksheet/PageSetup.php | 149 ++++++------- Classes/PHPExcel/Worksheet/Protection.php | 110 +++++---- Classes/PHPExcel/Writer/Abstract.php | 20 +- Classes/PHPExcel/Writer/Excel2007.php | 4 +- Classes/PHPExcel/Writer/Excel2007/Chart.php | 49 ++-- .../PHPExcel/Writer/Excel2007/Comments.php | 112 +++++----- .../Writer/Excel2007/ContentTypes.php | 209 +++++++++--------- .../PHPExcel/Writer/Excel2007/Worksheet.php | 28 +-- 8 files changed, 371 insertions(+), 310 deletions(-) diff --git a/Classes/PHPExcel/Worksheet/PageSetup.php b/Classes/PHPExcel/Worksheet/PageSetup.php index 6a98d47b..e5fe06ac 100644 --- a/Classes/PHPExcel/Worksheet/PageSetup.php +++ b/Classes/PHPExcel/Worksheet/PageSetup.php @@ -107,81 +107,81 @@ class PHPExcel_Worksheet_PageSetup { /* Paper size */ - const PAPERSIZE_LETTER = 1; + const PAPERSIZE_LETTER = 1; const PAPERSIZE_LETTER_SMALL = 2; - const PAPERSIZE_TABLOID = 3; - const PAPERSIZE_LEDGER = 4; - const PAPERSIZE_LEGAL = 5; - const PAPERSIZE_STATEMENT = 6; - const PAPERSIZE_EXECUTIVE = 7; - const PAPERSIZE_A3 = 8; - const PAPERSIZE_A4 = 9; + const PAPERSIZE_TABLOID = 3; + const PAPERSIZE_LEDGER = 4; + const PAPERSIZE_LEGAL = 5; + const PAPERSIZE_STATEMENT = 6; + const PAPERSIZE_EXECUTIVE = 7; + const PAPERSIZE_A3 = 8; + const PAPERSIZE_A4 = 9; const PAPERSIZE_A4_SMALL = 10; - const PAPERSIZE_A5 = 11; - const PAPERSIZE_B4 = 12; - const PAPERSIZE_B5 = 13; - const PAPERSIZE_FOLIO = 14; - const PAPERSIZE_QUARTO = 15; - const PAPERSIZE_STANDARD_1 = 16; - const PAPERSIZE_STANDARD_2 = 17; + const PAPERSIZE_A5 = 11; + const PAPERSIZE_B4 = 12; + const PAPERSIZE_B5 = 13; + const PAPERSIZE_FOLIO = 14; + const PAPERSIZE_QUARTO = 15; + const PAPERSIZE_STANDARD_1 = 16; + const PAPERSIZE_STANDARD_2 = 17; const PAPERSIZE_NOTE = 18; const PAPERSIZE_NO9_ENVELOPE = 19; - const PAPERSIZE_NO10_ENVELOPE = 20; - const PAPERSIZE_NO11_ENVELOPE = 21; - const PAPERSIZE_NO12_ENVELOPE = 22; - const PAPERSIZE_NO14_ENVELOPE = 23; - const PAPERSIZE_C = 24; - const PAPERSIZE_D = 25; - const PAPERSIZE_E = 26; - const PAPERSIZE_DL_ENVELOPE = 27; - const PAPERSIZE_C5_ENVELOPE = 28; - const PAPERSIZE_C3_ENVELOPE = 29; - const PAPERSIZE_C4_ENVELOPE = 30; - const PAPERSIZE_C6_ENVELOPE = 31; + const PAPERSIZE_NO10_ENVELOPE = 20; + const PAPERSIZE_NO11_ENVELOPE = 21; + const PAPERSIZE_NO12_ENVELOPE = 22; + const PAPERSIZE_NO14_ENVELOPE = 23; + const PAPERSIZE_C = 24; + const PAPERSIZE_D = 25; + const PAPERSIZE_E = 26; + const PAPERSIZE_DL_ENVELOPE = 27; + const PAPERSIZE_C5_ENVELOPE = 28; + const PAPERSIZE_C3_ENVELOPE = 29; + const PAPERSIZE_C4_ENVELOPE = 30; + const PAPERSIZE_C6_ENVELOPE = 31; const PAPERSIZE_C65_ENVELOPE = 32; - const PAPERSIZE_B4_ENVELOPE = 33; - const PAPERSIZE_B5_ENVELOPE = 34; - const PAPERSIZE_B6_ENVELOPE = 35; - const PAPERSIZE_ITALY_ENVELOPE = 36; + const PAPERSIZE_B4_ENVELOPE = 33; + const PAPERSIZE_B5_ENVELOPE = 34; + const PAPERSIZE_B6_ENVELOPE = 35; + const PAPERSIZE_ITALY_ENVELOPE = 36; const PAPERSIZE_MONARCH_ENVELOPE = 37; - const PAPERSIZE_6_3_4_ENVELOPE = 38; - const PAPERSIZE_US_STANDARD_FANFOLD = 39; - const PAPERSIZE_GERMAN_STANDARD_FANFOLD = 40; + const PAPERSIZE_6_3_4_ENVELOPE = 38; + const PAPERSIZE_US_STANDARD_FANFOLD = 39; + const PAPERSIZE_GERMAN_STANDARD_FANFOLD = 40; const PAPERSIZE_GERMAN_LEGAL_FANFOLD = 41; - const PAPERSIZE_ISO_B4 = 42; + const PAPERSIZE_ISO_B4 = 42; const PAPERSIZE_JAPANESE_DOUBLE_POSTCARD = 43; const PAPERSIZE_STANDARD_PAPER_1 = 44; const PAPERSIZE_STANDARD_PAPER_2 = 45; const PAPERSIZE_STANDARD_PAPER_3 = 46; - const PAPERSIZE_INVITE_ENVELOPE = 47; - const PAPERSIZE_LETTER_EXTRA_PAPER = 48; - const PAPERSIZE_LEGAL_EXTRA_PAPER = 49; - const PAPERSIZE_TABLOID_EXTRA_PAPER = 50; - const PAPERSIZE_A4_EXTRA_PAPER = 51; - const PAPERSIZE_LETTER_TRANSVERSE_PAPER = 52; - const PAPERSIZE_A4_TRANSVERSE_PAPER = 53; - const PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER = 54; - const PAPERSIZE_SUPERA_SUPERA_A4_PAPER = 55; - const PAPERSIZE_SUPERB_SUPERB_A3_PAPER = 56; - const PAPERSIZE_LETTER_PLUS_PAPER = 57; - const PAPERSIZE_A4_PLUS_PAPER = 58; - const PAPERSIZE_A5_TRANSVERSE_PAPER = 59; - const PAPERSIZE_JIS_B5_TRANSVERSE_PAPER = 60; - const PAPERSIZE_A3_EXTRA_PAPER = 61; - const PAPERSIZE_A5_EXTRA_PAPER = 62; - const PAPERSIZE_ISO_B5_EXTRA_PAPER = 63; + const PAPERSIZE_INVITE_ENVELOPE = 47; + const PAPERSIZE_LETTER_EXTRA_PAPER = 48; + const PAPERSIZE_LEGAL_EXTRA_PAPER = 49; + const PAPERSIZE_TABLOID_EXTRA_PAPER = 50; + const PAPERSIZE_A4_EXTRA_PAPER = 51; + const PAPERSIZE_LETTER_TRANSVERSE_PAPER = 52; + const PAPERSIZE_A4_TRANSVERSE_PAPER = 53; + const PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER = 54; + const PAPERSIZE_SUPERA_SUPERA_A4_PAPER = 55; + const PAPERSIZE_SUPERB_SUPERB_A3_PAPER = 56; + const PAPERSIZE_LETTER_PLUS_PAPER = 57; + const PAPERSIZE_A4_PLUS_PAPER = 58; + const PAPERSIZE_A5_TRANSVERSE_PAPER = 59; + const PAPERSIZE_JIS_B5_TRANSVERSE_PAPER = 60; + const PAPERSIZE_A3_EXTRA_PAPER = 61; + const PAPERSIZE_A5_EXTRA_PAPER = 62; + const PAPERSIZE_ISO_B5_EXTRA_PAPER = 63; const PAPERSIZE_A2_PAPER = 64; - const PAPERSIZE_A3_TRANSVERSE_PAPER = 65; - const PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER = 66; + const PAPERSIZE_A3_TRANSVERSE_PAPER = 65; + const PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER = 66; /* Page orientation */ - const ORIENTATION_DEFAULT = 'default'; - const ORIENTATION_LANDSCAPE = 'landscape'; - const ORIENTATION_PORTRAIT = 'portrait'; + const ORIENTATION_DEFAULT = 'default'; + const ORIENTATION_LANDSCAPE = 'landscape'; + const ORIENTATION_PORTRAIT = 'portrait'; /* Print Range Set Method */ - const SETPRINTRANGE_OVERWRITE = 'O'; - const SETPRINTRANGE_INSERT = 'I'; + const SETPRINTRANGE_OVERWRITE = 'O'; + const SETPRINTRANGE_INSERT = 'I'; /** @@ -189,14 +189,14 @@ class PHPExcel_Worksheet_PageSetup * * @var int */ - private $_paperSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER; + private $_paperSize = PHPExcel_Worksheet_PageSetup::PAPERSIZE_LETTER; /** * Orientation * * @var string */ - private $_orientation = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT; + private $_orientation = PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT; /** * Scale (Print Scale) @@ -206,7 +206,7 @@ class PHPExcel_Worksheet_PageSetup * * @var int? */ - private $_scale = 100; + private $_scale = 100; /** * Fit To Page @@ -214,7 +214,7 @@ class PHPExcel_Worksheet_PageSetup * * @var boolean */ - private $_fitToPage = FALSE; + private $_fitToPage = false; /** * Fit To Height @@ -251,28 +251,28 @@ class PHPExcel_Worksheet_PageSetup * * @var boolean */ - private $_horizontalCentered = FALSE; + private $_horizontalCentered = false; /** * Center page vertically * * @var boolean */ - private $_verticalCentered = FALSE; + private $_verticalCentered = false; /** * Print area * * @var string */ - private $_printArea = NULL; + private $_printArea = null; /** * First page number * * @var int */ - private $_firstPageNumber = NULL; + private $_firstPageNumber = null; /** * Create a new PHPExcel_Worksheet_PageSetup @@ -286,7 +286,8 @@ class PHPExcel_Worksheet_PageSetup * * @return int */ - public function getPaperSize() { + public function getPaperSize() + { return $this->_paperSize; } @@ -370,7 +371,7 @@ class PHPExcel_Worksheet_PageSetup * @param boolean $pValue * @return PHPExcel_Worksheet_PageSetup */ - public function setFitToPage($pValue = TRUE) { + public function setFitToPage($pValue = true) { $this->_fitToPage = $pValue; return $this; } @@ -391,10 +392,10 @@ class PHPExcel_Worksheet_PageSetup * @param boolean $pUpdate Update fitToPage so it applies rather than scaling * @return PHPExcel_Worksheet_PageSetup */ - public function setFitToHeight($pValue = 1, $pUpdate = TRUE) { + public function setFitToHeight($pValue = 1, $pUpdate = true) { $this->_fitToHeight = $pValue; if ($pUpdate) { - $this->_fitToPage = TRUE; + $this->_fitToPage = true; } return $this; } @@ -415,10 +416,10 @@ class PHPExcel_Worksheet_PageSetup * @param boolean $pUpdate Update fitToPage so it applies rather than scaling * @return PHPExcel_Worksheet_PageSetup */ - public function setFitToWidth($pValue = 1, $pUpdate = TRUE) { + public function setFitToWidth($pValue = 1, $pUpdate = true) { $this->_fitToWidth = $pValue; if ($pUpdate) { - $this->_fitToPage = TRUE; + $this->_fitToPage = true; } return $this; } @@ -610,7 +611,7 @@ class PHPExcel_Worksheet_PageSetup */ public function clearPrintArea($index = 0) { if ($index == 0) { - $this->_printArea = NULL; + $this->_printArea = null; } else { $printAreas = explode(',', $this->_printArea); if (isset($printAreas[$index-1])) { diff --git a/Classes/PHPExcel/Worksheet/Protection.php b/Classes/PHPExcel/Worksheet/Protection.php index af341988..d6ab223a 100644 --- a/Classes/PHPExcel/Worksheet/Protection.php +++ b/Classes/PHPExcel/Worksheet/Protection.php @@ -166,8 +166,9 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function isProtectionEnabled() { - return $this->_sheet || + function isProtectionEnabled() + { + return $this->_sheet || $this->_objects || $this->_scenarios || $this->_formatCells || @@ -190,7 +191,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getSheet() { + function getSheet() + { return $this->_sheet; } @@ -200,7 +202,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setSheet($pValue = false) { + function setSheet($pValue = false) + { $this->_sheet = $pValue; return $this; } @@ -210,7 +213,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getObjects() { + function getObjects() + { return $this->_objects; } @@ -220,7 +224,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setObjects($pValue = false) { + function setObjects($pValue = false) + { $this->_objects = $pValue; return $this; } @@ -230,7 +235,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getScenarios() { + function getScenarios() + { return $this->_scenarios; } @@ -240,7 +246,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setScenarios($pValue = false) { + function setScenarios($pValue = false) + { $this->_scenarios = $pValue; return $this; } @@ -250,7 +257,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getFormatCells() { + function getFormatCells() + { return $this->_formatCells; } @@ -260,7 +268,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setFormatCells($pValue = false) { + function setFormatCells($pValue = false) + { $this->_formatCells = $pValue; return $this; } @@ -270,7 +279,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getFormatColumns() { + function getFormatColumns() + { return $this->_formatColumns; } @@ -280,7 +290,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setFormatColumns($pValue = false) { + function setFormatColumns($pValue = false) + { $this->_formatColumns = $pValue; return $this; } @@ -290,7 +301,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getFormatRows() { + function getFormatRows() + { return $this->_formatRows; } @@ -300,7 +312,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setFormatRows($pValue = false) { + function setFormatRows($pValue = false) + { $this->_formatRows = $pValue; return $this; } @@ -310,7 +323,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getInsertColumns() { + function getInsertColumns() + { return $this->_insertColumns; } @@ -320,7 +334,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setInsertColumns($pValue = false) { + function setInsertColumns($pValue = false) + { $this->_insertColumns = $pValue; return $this; } @@ -330,7 +345,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getInsertRows() { + function getInsertRows() + { return $this->_insertRows; } @@ -340,7 +356,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setInsertRows($pValue = false) { + function setInsertRows($pValue = false) + { $this->_insertRows = $pValue; return $this; } @@ -350,7 +367,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getInsertHyperlinks() { + function getInsertHyperlinks() + { return $this->_insertHyperlinks; } @@ -360,7 +378,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setInsertHyperlinks($pValue = false) { + function setInsertHyperlinks($pValue = false) + { $this->_insertHyperlinks = $pValue; return $this; } @@ -370,7 +389,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getDeleteColumns() { + function getDeleteColumns() + { return $this->_deleteColumns; } @@ -380,7 +400,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setDeleteColumns($pValue = false) { + function setDeleteColumns($pValue = false) + { $this->_deleteColumns = $pValue; return $this; } @@ -390,7 +411,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getDeleteRows() { + function getDeleteRows() + { return $this->_deleteRows; } @@ -400,7 +422,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setDeleteRows($pValue = false) { + function setDeleteRows($pValue = false) + { $this->_deleteRows = $pValue; return $this; } @@ -410,7 +433,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getSelectLockedCells() { + function getSelectLockedCells() + { return $this->_selectLockedCells; } @@ -420,7 +444,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setSelectLockedCells($pValue = false) { + function setSelectLockedCells($pValue = false) + { $this->_selectLockedCells = $pValue; return $this; } @@ -430,7 +455,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getSort() { + function getSort() + { return $this->_sort; } @@ -440,7 +466,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setSort($pValue = false) { + function setSort($pValue = false) + { $this->_sort = $pValue; return $this; } @@ -450,7 +477,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getAutoFilter() { + function getAutoFilter() + { return $this->_autoFilter; } @@ -460,7 +488,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setAutoFilter($pValue = false) { + function setAutoFilter($pValue = false) + { $this->_autoFilter = $pValue; return $this; } @@ -470,7 +499,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getPivotTables() { + function getPivotTables() + { return $this->_pivotTables; } @@ -480,7 +510,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setPivotTables($pValue = false) { + function setPivotTables($pValue = false) + { $this->_pivotTables = $pValue; return $this; } @@ -490,7 +521,8 @@ class PHPExcel_Worksheet_Protection * * @return boolean */ - function getSelectUnlockedCells() { + function getSelectUnlockedCells() + { return $this->_selectUnlockedCells; } @@ -500,7 +532,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pValue * @return PHPExcel_Worksheet_Protection */ - function setSelectUnlockedCells($pValue = false) { + function setSelectUnlockedCells($pValue = false) + { $this->_selectUnlockedCells = $pValue; return $this; } @@ -510,7 +543,8 @@ class PHPExcel_Worksheet_Protection * * @return string */ - function getPassword() { + function getPassword() + { return $this->_password; } @@ -521,7 +555,8 @@ class PHPExcel_Worksheet_Protection * @param boolean $pAlreadyHashed If the password has already been hashed, set this to true * @return PHPExcel_Worksheet_Protection */ - function setPassword($pValue = '', $pAlreadyHashed = false) { + function setPassword($pValue = '', $pAlreadyHashed = false) + { if (!$pAlreadyHashed) { $pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue); } @@ -532,7 +567,8 @@ class PHPExcel_Worksheet_Protection /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ - public function __clone() { + public function __clone() + { $vars = get_object_vars($this); foreach ($vars as $key => $value) { if (is_object($value)) { diff --git a/Classes/PHPExcel/Writer/Abstract.php b/Classes/PHPExcel/Writer/Abstract.php index 911dc5dd..a0f14100 100644 --- a/Classes/PHPExcel/Writer/Abstract.php +++ b/Classes/PHPExcel/Writer/Abstract.php @@ -65,7 +65,8 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter * * @return boolean */ - public function getIncludeCharts() { + public function getIncludeCharts() + { return $this->_includeCharts; } @@ -93,7 +94,8 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter * * @return boolean */ - public function getPreCalculateFormulas() { + public function getPreCalculateFormulas() + { return $this->_preCalculateFormulas; } @@ -105,7 +107,8 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter * @param boolean $pValue Pre-Calculate Formulas? * @return PHPExcel_Writer_IWriter */ - public function setPreCalculateFormulas($pValue = TRUE) { + public function setPreCalculateFormulas($pValue = true) + { $this->_preCalculateFormulas = (boolean) $pValue; return $this; } @@ -115,7 +118,8 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter * * @return boolean */ - public function getUseDiskCaching() { + public function getUseDiskCaching() + { return $this->_useDiskCaching; } @@ -127,10 +131,11 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter * @throws PHPExcel_Writer_Exception when directory does not exist * @return PHPExcel_Writer_Excel2007 */ - public function setUseDiskCaching($pValue = FALSE, $pDirectory = NULL) { + public function setUseDiskCaching($pValue = false, $pDirectory = null) + { $this->_useDiskCaching = $pValue; - if ($pDirectory !== NULL) { + if ($pDirectory !== null) { if (is_dir($pDirectory)) { $this->_diskCachingDirectory = $pDirectory; } else { @@ -145,7 +150,8 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter * * @return string */ - public function getDiskCachingDirectory() { + public function getDiskCachingDirectory() + { return $this->_diskCachingDirectory; } } diff --git a/Classes/PHPExcel/Writer/Excel2007.php b/Classes/PHPExcel/Writer/Excel2007.php index 756bf4dc..e7f26ff5 100644 --- a/Classes/PHPExcel/Writer/Excel2007.php +++ b/Classes/PHPExcel/Writer/Excel2007.php @@ -257,7 +257,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE if ($this->_spreadSheet->hasRibbonBinObjects()) { $tmpRootPath=dirname($tmpRibbonTarget).'/'; $ribbonBinObjects=$this->_spreadSheet->getRibbonBinObjects('data');//the files to write - foreach ($ribbonBinObjects as $aPath=>$aContent) { + foreach ($ribbonBinObjects as $aPath => $aContent) { $objZip->addFromString($tmpRootPath.$aPath, $aContent); } //the rels for files @@ -494,7 +494,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE * * @return PHPExcel_HashTable */ - public function getNumFmtHashTable() + public function getNumFmtHashTable() { return $this->_numFmtHashTable; } diff --git a/Classes/PHPExcel/Writer/Excel2007/Chart.php b/Classes/PHPExcel/Writer/Excel2007/Chart.php index 93cff286..6aefa80a 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Chart.php +++ b/Classes/PHPExcel/Writer/Excel2007/Chart.php @@ -32,7 +32,8 @@ * @package PHPExcel_Writer_Excel2007 * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) */ -class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPart { +class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPart +{ /** * Write charts to XML format * @@ -41,7 +42,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * @return string XML Output * @throws PHPExcel_Writer_Exception */ - public function writeChart(PHPExcel_Chart $pChart = null) { + public function writeChart(PHPExcel_Chart $pChart = null) + { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { @@ -115,7 +117,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writeTitle(PHPExcel_Chart_Title $title = null, $objWriter) { + private function _writeTitle(PHPExcel_Chart_Title $title = null, $objWriter) + { if (is_null($title)) { return; } @@ -159,7 +162,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writeLegend(PHPExcel_Chart_Legend $legend = null, $objWriter) { + private function _writeLegend(PHPExcel_Chart_Legend $legend = null, $objWriter) + { if (is_null($legend)) { return; } @@ -210,10 +214,10 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * @param PHPExcel_Chart_Axis $xAxis * @param PHPExcel_Chart_Axis $yAxis * @param PHPExcel_Shared_XMLWriter $objWriter XML Writer - * + * * @throws PHPExcel_Writer_Exception */ - private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea, PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, $objWriter, PHPExcel_Worksheet $pSheet, PHPExcel_Chart_Axis $xAxis, PHPExcel_Chart_Axis $yAxis, PHPExcel_Chart_GridLines $majorGridlines, PHPExcel_Chart_GridLines $minorGridlines ) + private function _writePlotArea(PHPExcel_Chart_PlotArea $plotArea, PHPExcel_Chart_Title $xAxisLabel = null, PHPExcel_Chart_Title $yAxisLabel = null, $objWriter, PHPExcel_Worksheet $pSheet, PHPExcel_Chart_Axis $xAxis, PHPExcel_Chart_Axis $yAxis, PHPExcel_Chart_GridLines $majorGridlines, PHPExcel_Chart_GridLines $minorGridlines) { if (is_null($plotArea)) { return; @@ -349,7 +353,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writeDataLbls($objWriter, $chartLayout) { + private function _writeDataLbls($objWriter, $chartLayout) + { $objWriter->startElement('c:dLbls'); $objWriter->startElement('c:showLegendKey'); @@ -403,7 +408,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis) { + private function _writeCatAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $xAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis) + { $objWriter->startElement('c:catAx'); if ($id1 > 0) { @@ -524,7 +530,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writeValAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines) { + private function _writeValAx($objWriter, PHPExcel_Chart_PlotArea $plotArea, $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, $xAxis, $yAxis, $majorGridlines, $minorGridlines) + { $objWriter->startElement('c:valAx'); if ($id2 > 0) { @@ -1004,7 +1011,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * @return string|array * @throws PHPExcel_Writer_Exception */ - private static function _getChartType($plotArea) { + private static function _getChartType($plotArea) + { $groupCount = $plotArea->getPlotGroupCount(); if ($groupCount == 1) { @@ -1036,7 +1044,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType, PHPExcel_Worksheet $pSheet ) { + private function _writePlotGroup($plotGroup, $groupType, $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType, PHPExcel_Worksheet $pSheet) + { if (is_null($plotGroup)) { return; } @@ -1209,7 +1218,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writePlotSeriesLabel($plotSeriesLabel, $objWriter) { + private function _writePlotSeriesLabel($plotSeriesLabel, $objWriter) + { if (is_null($plotSeriesLabel)) { return; } @@ -1246,7 +1256,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, $dataType = 'str', PHPExcel_Worksheet $pSheet) { + private function _writePlotSeriesValues($plotSeriesValues, $objWriter, $groupType, $dataType = 'str', PHPExcel_Worksheet $pSheet) + { if (is_null($plotSeriesValues)) { return; } @@ -1337,7 +1348,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet) { + private function _writeBubbles($plotSeriesValues, $objWriter, PHPExcel_Worksheet $pSheet) + { if (is_null($plotSeriesValues)) { return; } @@ -1383,7 +1395,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writeLayout(PHPExcel_Chart_Layout $layout = null, $objWriter) { + private function _writeLayout(PHPExcel_Chart_Layout $layout = null, $objWriter) + { $objWriter->startElement('c:layout'); if (!is_null($layout)) { @@ -1451,7 +1464,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writeAlternateContent($objWriter) { + private function _writeAlternateContent($objWriter) + { $objWriter->startElement('mc:AlternateContent'); $objWriter->writeAttribute('xmlns:mc', 'http://schemas.openxmlformats.org/markup-compatibility/2006'); @@ -1480,7 +1494,8 @@ class PHPExcel_Writer_Excel2007_Chart extends PHPExcel_Writer_Excel2007_WriterPa * * @throws PHPExcel_Writer_Exception */ - private function _writePrintSettings($objWriter) { + private function _writePrintSettings($objWriter) + { $objWriter->startElement('c:printSettings'); $objWriter->startElement('c:headerFooter'); diff --git a/Classes/PHPExcel/Writer/Excel2007/Comments.php b/Classes/PHPExcel/Writer/Excel2007/Comments.php index 61ba4ad0..95336e86 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Comments.php +++ b/Classes/PHPExcel/Writer/Excel2007/Comments.php @@ -71,19 +71,19 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write $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 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(); + // Loop through comments + $objWriter->startElement('commentList'); + foreach ($comments as $key => $value) { + $this->_writeComment($objWriter, $key, $value, $authors); + } + $objWriter->endElement(); $objWriter->endElement(); @@ -104,13 +104,13 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write { // comment $objWriter->startElement('comment'); - $objWriter->writeAttribute('ref', $pCellReference); - $objWriter->writeAttribute('authorId', $pAuthors[$pComment->getAuthor()]); + $objWriter->writeAttribute('ref', $pCellReference); + $objWriter->writeAttribute('authorId', $pAuthors[$pComment->getAuthor()]); - // text - $objWriter->startElement('text'); - $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $pComment->getText()); - $objWriter->endElement(); + // text + $objWriter->startElement('text'); + $this->getParentWriter()->getWriterPart('stringtable')->writeRichText($objWriter, $pComment->getText()); + $objWriter->endElement(); $objWriter->endElement(); } @@ -144,42 +144,42 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write $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(); + // 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(); - // 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'); + $objWriter->endElement(); - // 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(); + // 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(); - // Loop through comments - foreach ($comments as $key => $value) { - $this->_writeVMLComment($objWriter, $key, $value); - } + // 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(); @@ -205,22 +205,22 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write // 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'); + $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->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->writeAttribute('on', 't'); + $objWriter->writeAttribute('color', 'black'); + $objWriter->writeAttribute('obscured', 't'); $objWriter->endElement(); // v:path diff --git a/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php b/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php index 2ecf9320..ef572133 100644 --- a/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php +++ b/Classes/PHPExcel/Writer/Excel2007/ContentTypes.php @@ -60,125 +60,126 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W $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'); + // 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'); + // 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'); + // Rels + $this->_writeDefaultContentType($objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'); - // XML - $this->_writeDefaultContentType($objWriter, 'xml', 'application/xml'); + // XML + $this->_writeDefaultContentType($objWriter, 'xml', 'application/xml'); - // VML - $this->_writeDefaultContentType($objWriter, 'vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing'); + // 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'); + // 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'); } - } else {// no macros in workbook, so standard type - $this->_writeOverrideContentType($objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+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(); } - // DocProps - $this->_writeOverrideContentType($objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'); + if (!isset( $aMediaContentTypes[$extension])) { + $aMediaContentTypes[$extension] = $mimeType; - $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'); + $this->_writeDefaultContentType($objWriter, $extension, $mimeType); } - - // 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'); + } + 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()); - // 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())]); - } + $this->_writeDefaultContentType($objWriter, strtolower($image->getExtension()), $aMediaContentTypes[strtolower($image->getExtension())]); } } } + } $objWriter->endElement(); diff --git a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php index 176e44b1..cb153f8a 100644 --- a/Classes/PHPExcel/Writer/Excel2007/Worksheet.php +++ b/Classes/PHPExcel/Writer/Excel2007/Worksheet.php @@ -231,7 +231,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ // View Layout Type if ($pSheet->getSheetView()->getView() !== PHPExcel_Worksheet_SheetView::SHEETVIEW_NORMAL) { - $objWriter->writeAttribute('view', $pSheet->getSheetView()->getView()); + $objWriter->writeAttribute('view', $pSheet->getSheetView()->getView()); } // Gridlines @@ -294,15 +294,15 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ // Selection // if ($pane != '') { - // Only need to write selection element if we have a split pane - // We cheat a little by over-riding the active cell selection, setting it to the split cell - $objWriter->startElement('selection'); - if ($pane != '') { - $objWriter->writeAttribute('pane', $pane); - } - $objWriter->writeAttribute('activeCell', $activeCell); - $objWriter->writeAttribute('sqref', $activeCell); - $objWriter->endElement(); + // Only need to write selection element if we have a split pane + // We cheat a little by over-riding the active cell selection, setting it to the split cell + $objWriter->startElement('selection'); + if ($pane != '') { + $objWriter->writeAttribute('pane', $pane); + } + $objWriter->writeAttribute('activeCell', $activeCell); + $objWriter->writeAttribute('sqref', $activeCell); + $objWriter->endElement(); // } $objWriter->endElement(); @@ -760,7 +760,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ $range = PHPExcel_Cell::splitRange($autoFilterRange); $range = $range[0]; // Strip any worksheet ref - if (strpos($range[0],'!') !== false) { + if (strpos($range[0], '!') !== false) { list($ws, $range[0]) = explode('!', $range[0]); } $range = implode(':', $range); @@ -785,7 +785,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ ($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL) && ($rule->getValue() === '')) { // Filter rule for Blanks - $objWriter->writeAttribute('blank', 1); + $objWriter->writeAttribute('blank', 1); } elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) { // Dynamic Filter Rule $objWriter->writeAttribute('type', $rule->getGrouping()); @@ -812,7 +812,9 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ if ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP) { // Date Group filters foreach ($rule->getValue() as $key => $value) { - if ($value > '') $objWriter->writeAttribute($key, $value); + if ($value > '') { + $objWriter->writeAttribute($key, $value); + } } $objWriter->writeAttribute('dateTimeGrouping', $rule->getGrouping()); } else {