@@ -593,9 +593,10 @@ public static function absoluteCoordinate($pCoordinateString = 'A1')
593
593
/**
594
594
* Split range into coordinate strings
595
595
*
596
- * @param string $pRange e.g. 'B4:D9' or 'B4:D9,H2:O11'
596
+ * @param string $pRange e.g. 'B4:D9' or 'B4:D9,H2:O11' or 'B4'
597
597
* @return array Array containg one or more arrays containing one or two coordinate strings
598
598
* e.g. array('B4','D9') or array(array('B4','D9'),array('H2','O11'))
599
+ * or array('B4')
599
600
*/
600
601
public static function splitRange ($ pRange = 'A1:A1 ' )
601
602
{
@@ -636,7 +637,8 @@ public static function buildRange($pRange)
636
637
* Calculate range boundaries
637
638
*
638
639
* @param string $pRange Cell range (e.g. A1:A1)
639
- * @return array Range coordinates (Start Cell, End Cell) where Start Cell and End Cell are arrays (Column Number, Row Number)
640
+ * @return array Range coordinates array(Start Cell, End Cell)
641
+ * where Start Cell and End Cell are arrays (Column Number, Row Number)
640
642
*/
641
643
public static function rangeBoundaries ($ pRange = 'A1:A1 ' )
642
644
{
@@ -679,7 +681,8 @@ public static function rangeDimension($pRange = 'A1:A1')
679
681
* Calculate range boundaries
680
682
*
681
683
* @param string $pRange Cell range (e.g. A1:A1)
682
- * @return array Range boundaries (staring Column, starting Row, Final Column, Final Row)
684
+ * @return array Range coordinates array(Start Cell, End Cell)
685
+ * where Start Cell and End Cell are arrays (Column ID, Row Number)
683
686
*/
684
687
public static function getRangeBoundaries ($ pRange = 'A1:A1 ' )
685
688
{
@@ -772,7 +775,7 @@ public static function stringFromColumnIndex($pColumnIndex = 0)
772
775
/**
773
776
* Extract all cell references in range
774
777
*
775
- * @param string $pRange Range (e.g. A1 or A1:A10 or A1:A10 A100:A1000 )
778
+ * @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25 )
776
779
* @return array Array containing single cell references
777
780
*/
778
781
public static function extractAllCellReferencesInRange ($ pRange = 'A1 ' ) {
@@ -819,8 +822,16 @@ public static function extractAllCellReferencesInRange($pRange = 'A1') {
819
822
}
820
823
}
821
824
825
+ // Sort the result by column and row
826
+ $ sortKeys = array ();
827
+ foreach (array_unique ($ returnValue ) as $ coord ) {
828
+ list($ column,$ row ) = sscanf ($ coord ,'%[A-Z]%d ' );
829
+ $ sortKeys[sprintf('%3 s%0 9 d',$ column,$ row)] = $ coord;
830
+ }
831
+ ksort($ sortKeys);
832
+
822
833
// Return value
823
- return $ returnValue ;
834
+ return array_values( $ sortKeys) ;
824
835
}
825
836
826
837
/**
0 commit comments