@@ -172,9 +172,9 @@ public function getHighestRowAndColumn()
172
172
// Lookup highest column and highest row
173
173
$ col = ['A ' => '1A ' ];
174
174
$ row = [1 ];
175
+ $ c = '' ;
176
+ $ r = 0 ;
175
177
foreach ($ this ->getCoordinates () as $ coord ) {
176
- $ c = '' ;
177
- $ r = 0 ;
178
178
sscanf ($ coord , '%[A-Z]%d ' , $ c , $ r );
179
179
$ row [$ r ] = $ r ;
180
180
$ col [$ c ] = strlen ($ c ) . $ c ;
@@ -241,24 +241,21 @@ public function getCurrentRow()
241
241
public function getHighestColumn ($ row = null )
242
242
{
243
243
if ($ row === null ) {
244
- $ colRow = $ this ->getHighestRowAndColumn ();
245
-
246
- return $ colRow ['column ' ];
244
+ return $ this ->getHighestRowAndColumn ()['column ' ];
247
245
}
248
246
249
- $ columnList = [1 ];
247
+ $ maxColumn = '1A ' ;
248
+ $ c = '' ;
249
+ $ r = 0 ;
250
250
foreach ($ this ->getCoordinates () as $ coord ) {
251
- $ c = '' ;
252
- $ r = 0 ;
253
-
254
251
sscanf ($ coord , '%[A-Z]%d ' , $ c , $ r );
255
252
if ($ r != $ row ) {
256
253
continue ;
257
254
}
258
- $ columnList [] = Coordinate:: columnIndexFromString ( $ c );
255
+ $ maxColumn = max ( $ maxColumn , strlen ( $ c ) . $ c );
259
256
}
260
257
261
- return Coordinate:: stringFromColumnIndex (( int ) @ max ( $ columnList ) );
258
+ return substr ( $ maxColumn , 1 );
262
259
}
263
260
264
261
/**
@@ -272,24 +269,21 @@ public function getHighestColumn($row = null)
272
269
public function getHighestRow ($ column = null )
273
270
{
274
271
if ($ column === null ) {
275
- $ colRow = $ this ->getHighestRowAndColumn ();
276
-
277
- return $ colRow ['row ' ];
272
+ return $ this ->getHighestRowAndColumn ()['row ' ];
278
273
}
279
274
280
- $ rowList = [0 ];
275
+ $ maxRow = 1 ;
276
+ $ c = '' ;
277
+ $ r = 0 ;
281
278
foreach ($ this ->getCoordinates () as $ coord ) {
282
- $ c = '' ;
283
- $ r = 0 ;
284
-
285
279
sscanf ($ coord , '%[A-Z]%d ' , $ c , $ r );
286
280
if ($ c != $ column ) {
287
281
continue ;
288
282
}
289
- $ rowList [] = $ r ;
283
+ $ maxRow = max ( $ maxRow , $ r ) ;
290
284
}
291
285
292
- return max ( $ rowList ) ;
286
+ return $ maxRow ;
293
287
}
294
288
295
289
/**
@@ -347,10 +341,9 @@ public function cloneCellCollection(Worksheet $worksheet)
347
341
*/
348
342
public function removeRow ($ row ): void
349
343
{
344
+ $ c = '' ;
345
+ $ r = 0 ;
350
346
foreach ($ this ->getCoordinates () as $ coord ) {
351
- $ c = '' ;
352
- $ r = 0 ;
353
-
354
347
sscanf ($ coord , '%[A-Z]%d ' , $ c , $ r );
355
348
if ($ r == $ row ) {
356
349
$ this ->delete ($ coord );
@@ -365,10 +358,9 @@ public function removeRow($row): void
365
358
*/
366
359
public function removeColumn ($ column ): void
367
360
{
361
+ $ c = '' ;
362
+ $ r = 0 ;
368
363
foreach ($ this ->getCoordinates () as $ coord ) {
369
- $ c = '' ;
370
- $ r = 0 ;
371
-
372
364
sscanf ($ coord , '%[A-Z]%d ' , $ c , $ r );
373
365
if ($ c == $ column ) {
374
366
$ this ->delete ($ coord );
0 commit comments