Additional work on GH-161 for Breaks

This commit is contained in:
Mark Baker 2013-04-23 17:42:40 +01:00
parent 15bfe6b8d5
commit db1fcd5cd6
2 changed files with 34 additions and 20 deletions

View File

@ -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');
@ -276,8 +284,8 @@ class PHPExcel_ReferenceHelper
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);
} }
} }

View File

@ -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.');
} }