mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-29 08:46:03 +03:00
Additional work on GH-161 for Breaks
This commit is contained in:
parent
15bfe6b8d5
commit
db1fcd5cd6
@ -68,7 +68,15 @@ class PHPExcel_ReferenceHelper
|
|||||||
protected function __construct() {
|
protected function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function cellSort($a, $b) {
|
public static function columnSort($a, $b) {
|
||||||
|
return strcasecmp(strlen($a) . $a, strlen($b) . $b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function columnReverseSort($a, $b) {
|
||||||
|
return 1 - strcasecmp(strlen($a) . $a, strlen($b) . $b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function cellSort($a, $b) {
|
||||||
list($ac,$ar) = sscanf($a,'%[A-Z]%d');
|
list($ac,$ar) = sscanf($a,'%[A-Z]%d');
|
||||||
list($bc,$br) = sscanf($b,'%[A-Z]%d');
|
list($bc,$br) = sscanf($b,'%[A-Z]%d');
|
||||||
|
|
||||||
@ -78,7 +86,7 @@ class PHPExcel_ReferenceHelper
|
|||||||
return ($ar < $br) ? -1 : 1;
|
return ($ar < $br) ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function cellReverseSort($a, $b) {
|
public static function cellReverseSort($a, $b) {
|
||||||
list($ac,$ar) = sscanf($a,'%[A-Z]%d');
|
list($ac,$ar) = sscanf($a,'%[A-Z]%d');
|
||||||
list($bc,$br) = sscanf($b,'%[A-Z]%d');
|
list($bc,$br) = sscanf($b,'%[A-Z]%d');
|
||||||
|
|
||||||
@ -270,14 +278,14 @@ class PHPExcel_ReferenceHelper
|
|||||||
|
|
||||||
// Update worksheet: breaks
|
// Update worksheet: breaks
|
||||||
$aBreaks = $pSheet->getBreaks();
|
$aBreaks = $pSheet->getBreaks();
|
||||||
($pNumCols > 0 || $pNumRows > 0) ?
|
($pNumCols > 0 || $pNumRows > 0) ?
|
||||||
uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||||
uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellSort'));
|
uksort($aBreaks, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||||
foreach ($aBreaks as $key => $value) {
|
foreach ($aBreaks as $key => $value) {
|
||||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||||
if ($key != $newReference) {
|
if ($key != $newReference) {
|
||||||
$pSheet->setBreak( $newReference, $value );
|
$pSheet->setBreak($newReference, $value)
|
||||||
$pSheet->setBreak( $key, PHPExcel_Worksheet::BREAK_NONE );
|
->setBreak($key, PHPExcel_Worksheet::BREAK_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,9 +300,9 @@ class PHPExcel_ReferenceHelper
|
|||||||
|
|
||||||
// Update worksheet: hyperlinks
|
// Update worksheet: hyperlinks
|
||||||
$aHyperlinkCollection = $pSheet->getHyperlinkCollection();
|
$aHyperlinkCollection = $pSheet->getHyperlinkCollection();
|
||||||
($pNumCols > 0 || $pNumRows > 0) ?
|
($pNumCols > 0 || $pNumRows > 0) ?
|
||||||
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||||
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort'));
|
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||||
foreach ($aHyperlinkCollection as $key => $value) {
|
foreach ($aHyperlinkCollection as $key => $value) {
|
||||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||||
if ($key != $newReference) {
|
if ($key != $newReference) {
|
||||||
@ -305,9 +313,9 @@ class PHPExcel_ReferenceHelper
|
|||||||
|
|
||||||
// Update worksheet: data validations
|
// Update worksheet: data validations
|
||||||
$aDataValidationCollection = $pSheet->getDataValidationCollection();
|
$aDataValidationCollection = $pSheet->getDataValidationCollection();
|
||||||
($pNumCols > 0 || $pNumRows > 0) ?
|
($pNumCols > 0 || $pNumRows > 0) ?
|
||||||
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||||
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort'));
|
uksort($aDataValidationCollection, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||||
foreach ($aDataValidationCollection as $key => $value) {
|
foreach ($aDataValidationCollection as $key => $value) {
|
||||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||||
if ($key != $newReference) {
|
if ($key != $newReference) {
|
||||||
@ -327,9 +335,9 @@ class PHPExcel_ReferenceHelper
|
|||||||
|
|
||||||
// Update worksheet: protected cells
|
// Update worksheet: protected cells
|
||||||
$aProtectedCells = $pSheet->getProtectedCells();
|
$aProtectedCells = $pSheet->getProtectedCells();
|
||||||
($pNumCols > 0 || $pNumRows > 0) ?
|
($pNumCols > 0 || $pNumRows > 0) ?
|
||||||
uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
|
||||||
uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellSort'));
|
uksort($aProtectedCells, array('PHPExcel_ReferenceHelper','cellSort'));
|
||||||
foreach ($aProtectedCells as $key => $value) {
|
foreach ($aProtectedCells as $key => $value) {
|
||||||
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
|
||||||
if ($key != $newReference) {
|
if ($key != $newReference) {
|
||||||
|
@ -1604,7 +1604,13 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$pCell = strtoupper($pCell);
|
$pCell = strtoupper($pCell);
|
||||||
|
|
||||||
if ($pCell != '') {
|
if ($pCell != '') {
|
||||||
$this->_breaks[$pCell] = $pBreak;
|
if ($pBreak == PHPExcel_Worksheet::BREAK_NONE) {
|
||||||
|
if (isset($this->_breaks[$pCell])) {
|
||||||
|
unset($this->_breaks[$pCell]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->_breaks[$pCell] = $pBreak;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new PHPExcel_Exception('No cell coordinate specified.');
|
throw new PHPExcel_Exception('No cell coordinate specified.');
|
||||||
}
|
}
|
||||||
@ -2432,9 +2438,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
if ($formatData) {
|
if ($formatData) {
|
||||||
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
||||||
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
|
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
|
||||||
$returnValue[$rRef][$cRef],
|
$returnValue[$rRef][$cRef],
|
||||||
($style->getNumberFormat()) ?
|
($style->getNumberFormat()) ?
|
||||||
$style->getNumberFormat()->getFormatCode() :
|
$style->getNumberFormat()->getFormatCode() :
|
||||||
PHPExcel_Style_NumberFormat::FORMAT_GENERAL
|
PHPExcel_Style_NumberFormat::FORMAT_GENERAL
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user