PSR2 Fixes

This commit is contained in:
Progi1984 2015-05-16 13:04:38 +02:00
parent 4c8dd00dff
commit 1bf5ea414b
7 changed files with 441 additions and 365 deletions

View File

@ -752,16 +752,19 @@ class PHPExcel_Chart_Renderer_jpgraph
switch ($chartType) {
case 'area3DChart':
$dimensions = '3d';
// no break
case 'areaChart':
$this->renderPlotLine($i, true, true, $dimensions);
break;
case 'bar3DChart':
$dimensions = '3d';
// no break
case 'barChart':
$this->renderPlotBar($i, $dimensions);
break;
case 'line3DChart':
$dimensions = '3d';
// no break
case 'lineChart':
$this->renderPlotLine($i, false, true, $dimensions);
break;
@ -812,26 +815,31 @@ class PHPExcel_Chart_Renderer_jpgraph
switch ($chartType) {
case 'area3DChart':
$dimensions = '3d';
// no break
case 'areaChart':
$this->renderAreaChart($groupCount, $dimensions);
break;
case 'bar3DChart':
$dimensions = '3d';
// no break
case 'barChart':
$this->renderBarChart($groupCount, $dimensions);
break;
case 'line3DChart':
$dimensions = '3d';
// no break
case 'lineChart':
$this->renderLineChart($groupCount, $dimensions);
break;
case 'pie3DChart':
$dimensions = '3d';
// no break
case 'pieChart':
$this->renderPieChart($groupCount, $dimensions, false, false);
break;
case 'doughnut3DChart':
$dimensions = '3d';
// no break
case 'doughnutChart':
$this->renderPieChart($groupCount, $dimensions, true, true);
break;
@ -846,6 +854,7 @@ class PHPExcel_Chart_Renderer_jpgraph
break;
case 'surface3DChart':
$dimensions = '3d';
// no break
case 'surfaceChart':
$this->renderContourChart($groupCount, $dimensions);
break;

View File

@ -573,7 +573,8 @@ class PHPExcel_Helper_HTML
protected $richTextObject;
protected function initialise() {
protected function initialise()
{
$this->face = $this->size = $this->color = null;
$this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
@ -582,7 +583,8 @@ class PHPExcel_Helper_HTML
$this->stringData = '';
}
public function toRichTextObject($html) {
public function toRichTextObject($html)
{
$this->initialise();
// Create a new DOM object
@ -594,15 +596,17 @@ class PHPExcel_Helper_HTML
// Discard excess white space
$dom->preserveWhiteSpace = false;
$this->richTextObject = new PHPExcel_RichText();;
$this->richTextObject = new PHPExcel_RichText();
$this->parseElements($dom);
return $this->richTextObject;
}
protected function buildTextRun() {
protected function buildTextRun()
{
$text = $this->stringData;
if (trim($text) === '')
if (trim($text) === '') {
return;
}
$richtextRun = $this->richTextObject->createTextRun($this->stringData);
if ($this->face) {
@ -612,7 +616,7 @@ class PHPExcel_Helper_HTML
$richtextRun->getFont()->setSize($this->size);
}
if ($this->color) {
$richtextRun->getFont()->setColor( new PHPExcel_Style_Color( 'ff' . $this->color ) );
$richtextRun->getFont()->setColor(new PHPExcel_Style_Color('ff' . $this->color));
}
if ($this->bold) {
$richtextRun->getFont()->setBold(true);
@ -635,7 +639,8 @@ class PHPExcel_Helper_HTML
$this->stringData = '';
}
protected function rgbToColour($rgb) {
protected function rgbToColour($rgb)
{
preg_match_all('/\d+/', $rgb, $values);
foreach ($values[0] as &$value) {
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
@ -643,11 +648,13 @@ class PHPExcel_Helper_HTML
return implode($values[0]);
}
protected function colourNameLookup($rgb) {
protected function colourNameLookup($rgb)
{
return self::$colourMap[$rgb];
}
protected function startFontTag($tag) {
protected function startFontTag($tag)
{
foreach ($tag->attributes as $attribute) {
$attributeName = strtolower($attribute->name);
$attributeValue = $attribute->value;
@ -666,69 +673,85 @@ class PHPExcel_Helper_HTML
}
}
protected function endFontTag() {
protected function endFontTag()
{
$this->face = $this->size = $this->color = null;
}
protected function startBoldTag() {
protected function startBoldTag()
{
$this->bold = true;
}
protected function endBoldTag() {
protected function endBoldTag()
{
$this->bold = false;
}
protected function startItalicTag() {
protected function startItalicTag()
{
$this->italic = true;
}
protected function endItalicTag() {
protected function endItalicTag()
{
$this->italic = false;
}
protected function startUnderlineTag() {
protected function startUnderlineTag()
{
$this->underline = true;
}
protected function endUnderlineTag() {
protected function endUnderlineTag()
{
$this->underline = false;
}
protected function startSubscriptTag() {
protected function startSubscriptTag()
{
$this->subscript = true;
}
protected function endSubscriptTag() {
protected function endSubscriptTag()
{
$this->subscript = false;
}
protected function startSuperscriptTag() {
protected function startSuperscriptTag()
{
$this->superscript = true;
}
protected function endSuperscriptTag() {
protected function endSuperscriptTag()
{
$this->superscript = false;
}
protected function startStrikethruTag() {
protected function startStrikethruTag()
{
$this->strikethrough = true;
}
protected function endStrikethruTag() {
protected function endStrikethruTag()
{
$this->strikethrough = false;
}
protected function breakTag() {
protected function breakTag()
{
$this->stringData .= PHP_EOL;
}
protected function parseTextNode(DOMText $textNode) {
protected function parseTextNode(DOMText $textNode)
{
$domText = preg_replace('/\s+/u', ' ', ltrim($textNode->nodeValue));
$this->stringData .= $domText;
$this->buildTextRun();
}
protected function handleCallback($element, $callbackTag, $callbacks) {
protected function handleCallback($element, $callbackTag, $callbacks)
{
if (isset($callbacks[$callbackTag])) {
$elementHandler = $callbacks[$callbackTag];
if (method_exists($this, $elementHandler)) {
@ -737,7 +760,8 @@ class PHPExcel_Helper_HTML
}
}
protected function parseElementNode(DOMElement $element) {
protected function parseElementNode(DOMElement $element)
{
$callbackTag = strtolower($element->nodeName);
$this->stack[] = $callbackTag;
@ -750,7 +774,8 @@ class PHPExcel_Helper_HTML
$this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
}
protected function parseElements(DOMNode $element) {
protected function parseElements(DOMNode $element)
{
foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) {
$this->parseTextNode($child);

View File

@ -42,7 +42,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @var boolean
*/
protected $_readDataOnly = FALSE;
protected $_readDataOnly = false;
/**
* Read charts that are defined in the workbook?
@ -50,7 +50,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @var boolean
*/
protected $_includeCharts = FALSE;
protected $_includeCharts = false;
/**
* Restrict which sheets should be loaded?
@ -58,16 +58,16 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @var array of string
*/
protected $_loadSheetsOnly = NULL;
protected $_loadSheetsOnly = null;
/**
* PHPExcel_Reader_IReadFilter instance
*
* @var PHPExcel_Reader_IReadFilter
*/
protected $_readFilter = NULL;
protected $_readFilter = null;
protected $_fileHandle = NULL;
protected $_fileHandle = null;
/**
@ -77,7 +77,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return boolean
*/
public function getReadDataOnly() {
public function getReadDataOnly()
{
return $this->_readDataOnly;
}
@ -90,7 +91,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_IReader
*/
public function setReadDataOnly($pValue = FALSE) {
public function setReadDataOnly($pValue = false)
{
$this->_readDataOnly = $pValue;
return $this;
}
@ -103,7 +105,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return boolean
*/
public function getIncludeCharts() {
public function getIncludeCharts()
{
return $this->_includeCharts;
}
@ -117,7 +120,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_IReader
*/
public function setIncludeCharts($pValue = FALSE) {
public function setIncludeCharts($pValue = false)
{
$this->_includeCharts = (boolean) $pValue;
return $this;
}
@ -143,13 +147,13 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_IReader
*/
public function setLoadSheetsOnly($value = NULL)
public function setLoadSheetsOnly($value = null)
{
if ($value === NULL)
if ($value === null) {
return $this->setLoadAllSheets();
}
$this->_loadSheetsOnly = is_array($value) ?
$value : array($value);
$this->_loadSheetsOnly = is_array($value) ? $value : array($value);
return $this;
}
@ -161,7 +165,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/
public function setLoadAllSheets()
{
$this->_loadSheetsOnly = NULL;
$this->_loadSheetsOnly = null;
return $this;
}
@ -170,7 +174,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*
* @return PHPExcel_Reader_IReadFilter
*/
public function getReadFilter() {
public function getReadFilter()
{
return $this->_readFilter;
}
@ -180,7 +185,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* @param PHPExcel_Reader_IReadFilter $pValue
* @return PHPExcel_Reader_IReader
*/
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) {
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue)
{
$this->_readFilter = $pValue;
return $this;
}
@ -201,7 +207,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
// Open file
$this->_fileHandle = fopen($pFilename, 'r');
if ($this->_fileHandle === FALSE) {
if ($this->_fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
}
}
@ -219,11 +225,11 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
try {
$this->_openFile($pFilename);
} catch (Exception $e) {
return FALSE;
return false;
}
$readable = $this->_isValidFormat();
fclose ($this->_fileHandle);
fclose($this->_fileHandle);
return $readable;
}

View File

@ -62,7 +62,8 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
/**
* Create a new PHPExcel_Reader_Excel2003XML
*/
public function __construct() {
public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
@ -238,8 +239,8 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return $this->loadIntoExisting($pFilename, $objPHPExcel);
}
protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue)
{
$styleAttributeValue = strtolower($styleAttributeValue);
foreach ($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) {
@ -250,13 +251,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return false;
}
/**
* pixel units to excel width units(units of 1/256th of a character width)
* @param pxs
* @return
*/
protected static function _pixel2WidthUnits($pxs) {
protected static function _pixel2WidthUnits($pxs)
{
$UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219);
$widthUnits = 256 * ($pxs / 7);
@ -264,25 +265,24 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return $widthUnits;
}
/**
* excel width units(units of 1/256th of a character width) to pixel units
* @param widthUnits
* @return
*/
protected static function _widthUnits2Pixel($widthUnits) {
protected static function _widthUnits2Pixel($widthUnits)
{
$pixels = ($widthUnits / 256) * 7;
$offsetWidthUnits = $widthUnits % 256;
$pixels += round($offsetWidthUnits / (256 / 7));
return $pixels;
}
protected static function _hex2str($hex) {
protected static function _hex2str($hex)
{
return chr(hexdec($hex[1]));
}
/**
* Loads PHPExcel from file into PHPExcel instance
*
@ -321,7 +321,6 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC');
// Check if file exists
if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
@ -588,14 +587,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$columnID = 'A';
foreach ($rowData->Cell as $cell) {
$cell_ss = $cell->attributes($namespaces['ss']);
if (isset($cell_ss['Index'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($cell_ss['Index']-1);
}
$cellRange = $columnID.$rowID;
if ($this->getReadFilter() !== NULL) {
if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue;
}
@ -700,14 +698,22 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
foreach ($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0];
// Empty R reference is the current row
if ($rowReference == '') $rowReference = $rowID;
if ($rowReference == '') {
$rowReference = $rowID;
}
// Bracketed R references are relative to the current row
if ($rowReference{0} == '[') $rowReference = $rowID + trim($rowReference,'[]');
if ($rowReference{0} == '[') {
$rowReference = $rowID + trim($rowReference,'[]');
}
$columnReference = $cellReference[4][0];
// Empty C reference is the current column
if ($columnReference == '') $columnReference = $columnNumber;
if ($columnReference == '') {
$columnReference = $columnNumber;
}
// Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]');
if ($columnReference{0} == '[') {
$columnReference = $columnNumber + trim($columnReference,'[]');
}
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value, $A1CellReference, $cellReference[0][1],strlen($cellReference[0][0]));
}
@ -743,9 +749,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo $annotation,'<br />';
$annotation = strip_tags($node);
// echo 'Annotation: ', $annotation,'<br />';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
->setAuthor(self::_convertStringEncoding($author , $this->_charSet))
->setText($this->_parseRichText($annotation) );
$objPHPExcel->getActiveSheet()->getComment($columnID.$rowID)->setAuthor(self::_convertStringEncoding($author , $this->_charSet))->setText($this->_parseRichText($annotation) );
}
if (($cellIsSet) && (isset($cell_ss['StyleID']))) {
@ -756,7 +760,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// print_r($this->_styles[$style]);
// echo '<br />';
if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) {
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(NULL);
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(null);
}
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]);
}
@ -790,20 +794,21 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
}
protected static function _convertStringEncoding($string, $charset) {
protected static function _convertStringEncoding($string, $charset)
{
if ($charset != 'UTF-8') {
return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8', $charset);
return PHPExcel_Shared_String::ConvertEncoding($string, 'UTF-8', $charset);
}
return $string;
}
protected function _parseRichText($is = '') {
protected function _parseRichText($is = '')
{
$value = new PHPExcel_RichText();
$value->createText(self::_convertStringEncoding($is, $this->_charSet));
return $value;
}
}

View File

@ -436,9 +436,7 @@ class PHPExcel_ReferenceHelper
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows);
// Should the cell be updated? Move value and cellXf index from one cell to another.
if (($cellIndex >= $beforeColumnIndex) &&
($cell->getRow() >= $beforeRow)) {
if (($cellIndex >= $beforeColumnIndex) && ($cell->getRow() >= $beforeRow)) {
// Update cell styles
$pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex());
@ -471,7 +469,6 @@ class PHPExcel_ReferenceHelper
if ($pNumCols > 0 && $beforeColumnIndex - 2 > 0) {
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
// Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex($beforeColumnIndex - 2) . $i;
if ($pSheet->cellExists($coordinate)) {
@ -495,7 +492,6 @@ class PHPExcel_ReferenceHelper
if ($pNumRows > 0 && $beforeRow - 1 > 0) {
for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
// Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1);
if ($pSheet->cellExists($coordinate)) {
@ -547,7 +543,7 @@ class PHPExcel_ReferenceHelper
if ($pNumCols != 0) {
$autoFilterColumns = array_keys($autoFilter->getColumns());
if (count($autoFilterColumns) > 0) {
sscanf($pBefore,'%[A-Z]%d', $column, $row);
sscanf($pBefore, '%[A-Z]%d', $column, $row);
$columnIndex = PHPExcel_Cell::columnIndexFromString($column);
list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
if ($columnIndex <= $rangeEnd[0]) {
@ -577,7 +573,7 @@ class PHPExcel_ReferenceHelper
$toColRef = $rangeEnd[0]+$pNumCols;
do {
$autoFilter->shiftColumn(PHPExcel_Cell::stringFromColumnIndex($endColRef-1),PHPExcel_Cell::stringFromColumnIndex($toColRef-1));
$autoFilter->shiftColumn(PHPExcel_Cell::stringFromColumnIndex($endColRef-1), PHPExcel_Cell::stringFromColumnIndex($toColRef-1));
--$endColRef;
--$toColRef;
} while ($startColRef <= $endColRef);
@ -661,12 +657,12 @@ class PHPExcel_ReferenceHelper
$modified4 = substr($this->updateCellReference('$A'.$match[4], $pBefore, $pNumCols, $pNumRows), 2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4;
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = 100000;
$row = 10000000+trim($match[3],'$');
$row = 10000000 + trim($match[3],'$');
$cellIndex = $column.$row;
$newCellTokens[$cellIndex] = preg_quote($toString);
@ -686,11 +682,11 @@ class PHPExcel_ReferenceHelper
$modified4 = substr($this->updateCellReference($match[4].'$1', $pBefore, $pNumCols, $pNumRows), 0, -2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4;
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($match[3],'$')) + 100000;
$column = PHPExcel_Cell::columnIndexFromString(trim($match[3], '$')) + 100000;
$row = 10000000;
$cellIndex = $column.$row;
@ -711,13 +707,13 @@ class PHPExcel_ReferenceHelper
$modified4 = $this->updateCellReference($match[4], $pBefore, $pNumCols, $pNumRows);
if ($match[3].$match[4] !== $modified3.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4;
list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000;
$column = PHPExcel_Cell::columnIndexFromString(trim($column, '$')) + 100000;
$row = trim($row, '$') + 10000000;
$cellIndex = $column.$row;
$newCellTokens[$cellIndex] = preg_quote($toString);
@ -737,13 +733,13 @@ class PHPExcel_ReferenceHelper
$modified3 = $this->updateCellReference($match[3], $pBefore, $pNumCols, $pNumRows);
if ($match[3] !== $modified3) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
if (($match[2] == '') || (trim($match[2], "'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3;
list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000;
$column = PHPExcel_Cell::columnIndexFromString(trim($column, '$')) + 100000;
$row = trim($row, '$') + 10000000;
$cellIndex = $row . $column;
$newCellTokens[$cellIndex] = preg_quote($toString);
@ -761,7 +757,7 @@ class PHPExcel_ReferenceHelper
ksort($cellTokens);
ksort($newCellTokens);
} // Update cell references in the formula
$formulaBlock = str_replace('\\','',preg_replace($cellTokens, $newCellTokens, $formulaBlock));
$formulaBlock = str_replace('\\', '', preg_replace($cellTokens, $newCellTokens, $formulaBlock));
}
}
}
@ -839,7 +835,7 @@ class PHPExcel_ReferenceHelper
*/
private function _updateCellRange($pCellRange = 'A1:A1', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0)
{
if (strpos($pCellRange,':') !== false || strpos($pCellRange, ',') !== false) {
if (strpos($pCellRange, ':') !== false || strpos($pCellRange, ',') !== false) {
// Update range
$range = PHPExcel_Cell::splitRange($pCellRange);
$ic = count($range);

View File

@ -196,7 +196,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @var PHPExcel_Worksheet_AutoFilter
*/
private $_autoFilter = NULL;
private $_autoFilter = null;
/**
* Freeze pane
@ -334,7 +334,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
{
// Set parent and title
$this->_parent = $pParent;
$this->setTitle($pTitle, FALSE);
$this->setTitle($pTitle, false);
// setTitle can change $pTitle
$this->setCodeName($this->getTitle());
$this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE);
@ -363,12 +363,12 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->_protection = new PHPExcel_Worksheet_Protection();
// Default row dimension
$this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(NULL);
$this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(null);
// Default column dimension
$this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(NULL);
$this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(null);
$this->_autoFilter = new PHPExcel_Worksheet_AutoFilter(NULL, $this);
$this->_autoFilter = new PHPExcel_Worksheet_AutoFilter(null, $this);
}
@ -377,10 +377,11 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* typically so that the worksheet object can be unset
*
*/
public function disconnectCells() {
if ( $this->_cellCollection !== NULL) {
public function disconnectCells()
{
if ($this->_cellCollection !== null) {
$this->_cellCollection->unsetWorksheetCells();
$this->_cellCollection = NULL;
$this->_cellCollection = null;
}
// detach ourself from the workbook, so that it can then delete this worksheet successfully
$this->_parent = null;
@ -390,9 +391,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* Code to execute when this worksheet is unset()
*
*/
function __destruct() {
PHPExcel_Calculation::getInstance($this->_parent)
->clearCalculationCacheForWorksheet($this->_title);
function __destruct()
{
PHPExcel_Calculation::getInstance($this->_parent)->clearCalculationCacheForWorksheet($this->_title);
$this->disconnectCells();
}
@ -402,7 +403,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return PHPExcel_CachedObjectStorage_xxx
*/
public function getCellCacheController() {
public function getCellCacheController()
{
return $this->_cellCollection;
} // function getCellCacheController()
@ -479,7 +481,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Re-order cell collection
return $this->sortCellCollection();
}
if ($this->_cellCollection !== NULL) {
if ($this->_cellCollection !== null) {
return $this->_cellCollection->getCellList();
}
return array();
@ -492,7 +494,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function sortCellCollection()
{
if ($this->_cellCollection !== NULL) {
if ($this->_cellCollection !== null) {
return $this->_cellCollection->getSortedCellList();
}
return array();
@ -725,7 +727,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// There is only something to do if there are some auto-size columns
if (!empty($autoSizes)) {
// build list of cells references that participate in a merge
$isMergeCell = array();
foreach ($this->getMergeCells() as $cells) {
@ -762,7 +763,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// adjust column widths
foreach ($autoSizes as $columnIndex => $width) {
if ($width == -1) $width = $this->getDefaultColumnDimension()->getWidth();
if ($width == -1) {
$width = $this->getDefaultColumnDimension()->getWidth();
}
$this->getColumnDimension($columnIndex)->setWidth($width);
}
}
@ -775,7 +778,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return PHPExcel
*/
public function getParent() {
public function getParent()
{
return $this->_parent;
}
@ -785,7 +789,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param PHPExcel $parent
* @return PHPExcel_Worksheet
*/
public function rebindParent(PHPExcel $parent) {
public function rebindParent(PHPExcel $parent)
{
if ($this->_parent !== null) {
$namedRanges = $this->_parent->getNamedRanges();
foreach ($namedRanges as $namedRange) {
@ -841,18 +846,18 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Use name, but append with lowest possible integer
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 29);
}
$i = 1;
while ($this->_parent->sheetNameExists($pValue . ' ' . $i)) {
++$i;
if ($i == 10) {
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,28);
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 28);
}
} elseif ($i == 100) {
if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
$pValue = PHPExcel_Shared_String::Substring($pValue,0,27);
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 27);
}
}
}
@ -871,9 +876,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$newTitle = $this->getTitle();
PHPExcel_Calculation::getInstance($this->_parent)
->renameCalculationCacheForWorksheet($oldTitle, $newTitle);
if ($updateFormulaCellReferences)
if ($updateFormulaCellReferences) {
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle);
}
}
return $this;
}
@ -883,7 +889,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return string Sheet state (visible, hidden, veryHidden)
*/
public function getSheetState() {
public function getSheetState()
{
return $this->_sheetState;
}
@ -893,7 +900,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $value Sheet state (visible, hidden, veryHidden)
* @return PHPExcel_Worksheet
*/
public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) {
public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE)
{
$this->_sheetState = $value;
return $this;
}
@ -1159,7 +1167,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if ($namedRange !== NULL) {
if ($namedRange !== null) {
$pCoordinate = $namedRange->getRange();
return $namedRange->getWorksheet()->getCell($pCoordinate);
}
@ -1207,29 +1215,26 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
{
$cell = $this->_cellCollection->addCacheData(
$pCoordinate,
new PHPExcel_Cell(
NULL,
PHPExcel_Cell_DataType::TYPE_NULL,
$this
)
new PHPExcel_Cell(null, PHPExcel_Cell_DataType::TYPE_NULL, $this)
);
$this->_cellCollectionIsSorted = false;
// Coordinates
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0])) {
$this->_cachedHighestColumn = $aCoordinates[0];
}
$this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]);
// Cell needs appropriate xfIndex from dimensions records
// but don't create dimension records if they don't already exist
$rowDimension = $this->getRowDimension($aCoordinates[1], FALSE);
$columnDimension = $this->getColumnDimension($aCoordinates[0], FALSE);
$rowDimension = $this->getRowDimension($aCoordinates[1], false);
$columnDimension = $this->getColumnDimension($aCoordinates[0], false);
if ($rowDimension !== NULL && $rowDimension->getXfIndex() > 0) {
if ($rowDimension !== null && $rowDimension->getXfIndex() > 0) {
// then there is a row dimension with explicit style, assign it to the cell
$cell->setXfIndex($rowDimension->getXfIndex());
} elseif ($columnDimension !== NULL && $columnDimension->getXfIndex() > 0) {
} elseif ($columnDimension !== null && $columnDimension->getXfIndex() > 0) {
// then there is a column dimension, assign it to the cell
$cell->setXfIndex($columnDimension->getXfIndex());
}
@ -1256,7 +1261,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if ($namedRange !== NULL) {
if ($namedRange !== null) {
$pCoordinate = $namedRange->getRange();
if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) {
if (!$namedRange->getLocalOnly()) {
@ -1265,16 +1270,17 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
throw new PHPExcel_Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
}
}
} else {
return false;
}
else { return false; }
}
// Uppercase coordinate
$pCoordinate = strtoupper($pCoordinate);
if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) {
if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) {
throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.');
} elseif (strpos($pCoordinate,'$') !== false) {
} elseif (strpos($pCoordinate, '$') !== false) {
throw new PHPExcel_Exception('Cell coordinate must not be absolute.');
} else {
// Coordinates
@ -1303,15 +1309,16 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param int $pRow Numeric index of the row
* @return PHPExcel_Worksheet_RowDimension
*/
public function getRowDimension($pRow = 1, $create = TRUE)
public function getRowDimension($pRow = 1, $create = true)
{
// Found
$found = null;
// Get row dimension
if (!isset($this->_rowDimensions[$pRow])) {
if (!$create)
return NULL;
if (!$create) {
return null;
}
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
$this->_cachedHighestRow = max($this->_cachedHighestRow, $pRow);
@ -1325,20 +1332,22 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $pColumn String index of the column
* @return PHPExcel_Worksheet_ColumnDimension
*/
public function getColumnDimension($pColumn = 'A', $create = TRUE)
public function getColumnDimension($pColumn = 'A', $create = true)
{
// Uppercase coordinate
$pColumn = strtoupper($pColumn);
// Fetch dimensions
if (!isset($this->_columnDimensions[$pColumn])) {
if (!$create)
return NULL;
if (!$create) {
return null;
}
$this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn);
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn))
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn)) {
$this->_cachedHighestColumn = $pColumn;
}
}
return $this->_columnDimensions[$pColumn];
}
@ -1488,8 +1497,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null)
{
if (!is_null($pColumn2) && !is_null($pRow2)) {
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' .
PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->getStyle($cellRange);
}
@ -1680,7 +1688,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Uppercase coordinate
$pRange = strtoupper($pRange);
if (strpos($pRange,':') !== false) {
if (strpos($pRange, ':') !== false) {
$this->_mergeCells[$pRange] = $pRange;
// make sure cells are created
@ -1699,7 +1707,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
for ($i = 1; $i < $count; $i++) {
$this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
}
} else {
throw new PHPExcel_Exception('Merge must be set on a range of cells.');
}
@ -1735,7 +1742,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Uppercase coordinate
$pRange = strtoupper($pRange);
if (strpos($pRange,':') !== false) {
if (strpos($pRange, ':') !== false) {
if (isset($this->_mergeCells[$pRange])) {
unset($this->_mergeCells[$pRange]);
} else {
@ -1783,7 +1790,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function setMergeCells($pValue = array())
{
$this->_mergeCells = $pValue;
return $this;
}
@ -1896,7 +1902,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function setAutoFilter($pValue)
{
$pRange = strtoupper($pValue);
if (is_string($pValue)) {
$this->_autoFilter->setRange($pValue);
} elseif (is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) {
@ -1931,7 +1936,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function removeAutoFilter()
{
$this->_autoFilter->setRange(NULL);
$this->_autoFilter->setRange(null);
return $this;
}
@ -1961,8 +1966,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
{
// Uppercase coordinate
$pCell = strtoupper($pCell);
if (strpos($pCell,':') === false && strpos($pCell,',') === false) {
if (strpos($pCell, ':') === false && strpos($pCell, ',') === false) {
$this->_freezePane = $pCell;
} else {
throw new PHPExcel_Exception('Freeze pane can not be set on a range of cells.');
@ -2001,7 +2005,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) {
public function insertNewRowBefore($pBefore = 1, $pNumRows = 1)
{
if ($pBefore >= 1) {
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore('A' . $pBefore, 0, $pNumRows, $this);
@ -2019,7 +2024,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1) {
public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1)
{
if (!is_numeric($pBefore)) {
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore($pBefore . '1', $pNumCols, 0, $this);
@ -2037,7 +2043,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) {
public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1)
{
if ($pBefore >= 0) {
return $this->insertNewColumnBefore(PHPExcel_Cell::stringFromColumnIndex($pBefore), $pNumCols);
} else {
@ -2053,7 +2060,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
public function removeRow($pRow = 1, $pNumRows = 1) {
public function removeRow($pRow = 1, $pNumRows = 1)
{
if ($pRow >= 1) {
$highestRow = $this->getHighestDataRow();
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
@ -2076,7 +2084,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
public function removeColumn($pColumn = 'A', $pNumCols = 1) {
public function removeColumn($pColumn = 'A', $pNumCols = 1)
{
if (!is_numeric($pColumn)) {
$highestColumn = $this->getHighestDataColumn();
$pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols);
@ -2100,7 +2109,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) {
public function removeColumnByIndex($pColumn = 0, $pNumCols = 1)
{
if ($pColumn >= 0) {
return $this->removeColumn(PHPExcel_Cell::stringFromColumnIndex($pColumn), $pNumCols);
} else {
@ -2113,7 +2123,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return boolean
*/
public function getShowGridlines() {
public function getShowGridlines()
{
return $this->_showGridlines;
}
@ -2123,7 +2134,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show gridlines (true/false)
* @return PHPExcel_Worksheet
*/
public function setShowGridlines($pValue = false) {
public function setShowGridlines($pValue = false)
{
$this->_showGridlines = $pValue;
return $this;
}
@ -2133,7 +2145,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return boolean
*/
public function getPrintGridlines() {
public function getPrintGridlines()
{
return $this->_printGridlines;
}
@ -2143,7 +2156,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Print gridlines (true/false)
* @return PHPExcel_Worksheet
*/
public function setPrintGridlines($pValue = false) {
public function setPrintGridlines($pValue = false)
{
$this->_printGridlines = $pValue;
return $this;
}
@ -2153,7 +2167,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return boolean
*/
public function getShowRowColHeaders() {
public function getShowRowColHeaders()
{
return $this->_showRowColHeaders;
}
@ -2163,7 +2178,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show row and column headers (true/false)
* @return PHPExcel_Worksheet
*/
public function setShowRowColHeaders($pValue = false) {
public function setShowRowColHeaders($pValue = false)
{
$this->_showRowColHeaders = $pValue;
return $this;
}
@ -2173,7 +2189,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return boolean
*/
public function getShowSummaryBelow() {
public function getShowSummaryBelow()
{
return $this->_showSummaryBelow;
}
@ -2183,7 +2200,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show summary below (true/false)
* @return PHPExcel_Worksheet
*/
public function setShowSummaryBelow($pValue = true) {
public function setShowSummaryBelow($pValue = true)
{
$this->_showSummaryBelow = $pValue;
return $this;
}
@ -2193,7 +2211,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return boolean
*/
public function getShowSummaryRight() {
public function getShowSummaryRight()
{
return $this->_showSummaryRight;
}
@ -2203,7 +2222,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show summary right (true/false)
* @return PHPExcel_Worksheet
*/
public function setShowSummaryRight($pValue = true) {
public function setShowSummaryRight($pValue = true)
{
$this->_showSummaryRight = $pValue;
return $this;
}
@ -2243,9 +2263,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Uppercase coordinate
$pCellCoordinate = strtoupper($pCellCoordinate);
if (strpos($pCellCoordinate,':') !== false || strpos($pCellCoordinate,',') !== false) {
if (strpos($pCellCoordinate, ':') !== false || strpos($pCellCoordinate, ',') !== false) {
throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells.');
} else if (strpos($pCellCoordinate,'$') !== false) {
} else if (strpos($pCellCoordinate, '$') !== false) {
throw new PHPExcel_Exception('Cell coordinate string must not be absolute.');
} else if ($pCellCoordinate == '') {
throw new PHPExcel_Exception('Cell coordinate can not be zero-length string.');
@ -2340,7 +2360,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Convert '1:3' to 'A1:XFD3'
$pCoordinate = preg_replace('/^([0-9]+):([0-9]+)$/', 'A${1}:XFD${2}', $pCoordinate);
if (strpos($pCoordinate,':') !== false || strpos($pCoordinate,',') !== false) {
if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) {
list($first, ) = PHPExcel_Cell::splitRange($pCoordinate);
$this->_activeCell = $first[0];
} else {
@ -2368,7 +2388,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return boolean
*/
public function getRightToLeft() {
public function getRightToLeft()
{
return $this->_rightToLeft;
}
@ -2378,7 +2399,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $value Right-to-left true/false
* @return PHPExcel_Worksheet
*/
public function setRightToLeft($value = false) {
public function setRightToLeft($value = false)
{
$this->_rightToLeft = $value;
return $this;
}
@ -2393,7 +2415,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception
* @return PHPExcel_Worksheet
*/
public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) {
public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false)
{
if (is_array($source)) {
// Convert a 1-D array to 2-D (for ease of looping)
if (!is_array(end($source))) {
@ -2439,7 +2462,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* True - Return rows and columns indexed by their actual row and column IDs
* @return array
*/
public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
{
// Returnvalue
$returnValue = array();
// Identify the range that we need to extract from the worksheet
@ -2511,14 +2535,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @return array
* @throws PHPExcel_Exception
*/
public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
{
$namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
if ($namedRange !== NULL) {
if ($namedRange !== null) {
$pWorkSheet = $namedRange->getWorksheet();
$pCellRange = $namedRange->getRange();
return $pWorkSheet->rangeToArray( $pCellRange,
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
return $pWorkSheet->rangeToArray($pCellRange, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
}
throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.');
@ -2535,7 +2559,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* True - Return rows and columns indexed by their actual row and column IDs
* @return array
*/
public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) {
public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
{
// Garbage collect...
$this->garbageCollect();
@ -2543,8 +2568,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$maxCol = $this->getHighestColumn();
$maxRow = $this->getHighestRow();
// Return
return $this->rangeToArray( 'A1:'.$maxCol.$maxRow,
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
return $this->rangeToArray('A1:'.$maxCol.$maxRow, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
}
/**
@ -2555,7 +2579,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return PHPExcel_Worksheet_RowIterator
*/
public function getRowIterator($startRow = 1, $endRow = null) {
public function getRowIterator($startRow = 1, $endRow = null)
{
return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow);
}
@ -2567,7 +2592,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return PHPExcel_Worksheet_ColumnIterator
*/
public function getColumnIterator($startColumn = 'A', $endColumn = null) {
public function getColumnIterator($startColumn = 'A', $endColumn = null)
{
return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn);
}
@ -2576,7 +2602,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return PHPExcel_Worksheet
*/
public function garbageCollect() {
public function garbageCollect()
{
// Flush cache
$this->_cellCollection->getCacheData('A1');
// Build a reference table from images
@ -2620,13 +2647,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return string Hash code
*/
public function getHashCode() {
public function getHashCode()
{
if ($this->_dirty) {
$this->_hash = md5( $this->_title .
$this->_autoFilter .
($this->_protection->isProtectionEnabled() ? 't' : 'f') .
__CLASS__
);
$this->_hash = md5($this->_title . $this->_autoFilter . ($this->_protection->isProtectionEnabled() ? 't' : 'f') . __CLASS__);
$this->_dirty = false;
}
return $this->_hash;
@ -2642,17 +2666,15 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param bool $returnRange Return range? (see example)
* @return mixed
*/
public static function extractSheetTitle($pRange, $returnRange = false) {
public static function extractSheetTitle($pRange, $returnRange = false)
{
// Sheet title included?
if (($sep = strpos($pRange, '!')) === false) {
return '';
}
if ($returnRange) {
return array(
trim(substr($pRange, 0, $sep),"'"),
substr($pRange, $sep + 1)
);
return array(trim(substr($pRange, 0, $sep),"'"), substr($pRange, $sep + 1));
}
return substr($pRange, $sep + 1);
@ -2774,7 +2796,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $range
* @return string Adjusted range value
*/
public function shrinkRangeToFit($range) {
public function shrinkRangeToFit($range)
{
$maxCol = $this->getHighestColumn();
$maxRow = $this->getHighestRow();
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
@ -2783,10 +2806,18 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
foreach ($rangeBlocks as &$rangeSet) {
$rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet);
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); }
if ($rangeBoundaries[0][1] > $maxRow) { $rangeBoundaries[0][1] = $maxRow; }
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); }
if ($rangeBoundaries[1][1] > $maxRow) { $rangeBoundaries[1][1] = $maxRow; }
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) {
$rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol);
}
if ($rangeBoundaries[0][1] > $maxRow) {
$rangeBoundaries[0][1] = $maxRow;
}
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) {
$rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol);
}
if ($rangeBoundaries[1][1] > $maxRow) {
$rangeBoundaries[1][1] = $maxRow;
}
$rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1];
}
unset($rangeSet);
@ -2802,7 +2833,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function getTabColor()
{
if ($this->_tabColor === NULL)
if ($this->_tabColor === null)
$this->_tabColor = new PHPExcel_Style_Color();
return $this->_tabColor;
@ -2828,7 +2859,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/
public function isTabColorSet()
{
return ($this->_tabColor !== NULL);
return ($this->_tabColor !== null);
}
/**
@ -2845,7 +2876,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
/**
* Implement PHP __clone to create a deep clone, not just a shallow copy.
*/
public function __clone() {
public function __clone()
{
foreach ($this as $key => $val) {
if ($key == '_parent') {
continue;
@ -2876,7 +2908,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @return objWorksheet
* @throws PHPExcel_Exception
*/
public function setCodeName($pValue=null) {
public function setCodeName($pValue=null)
{
// Is this a 'rename' or not?
if ($this->getCodeName() == $pValue) {
return $this;
@ -2924,14 +2957,16 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*
* @return null|string
*/
public function getCodeName() {
public function getCodeName()
{
return $this->_codeName;
}
/**
* Sheet has a code name ?
* @return boolean
*/
public function hasCodeName() {
public function hasCodeName()
{
return !(is_null($this->_codeName));
}
}