diff --git a/src/main/java/com/github/bingoohuang/excel2beans/ExcelToBeans.java b/src/main/java/com/github/bingoohuang/excel2beans/ExcelToBeans.java
index <HASH>..<HASH> 100644
--- a/src/main/java/com/github/bingoohuang/excel2beans/ExcelToBeans.java
+++ b/src/main/java/com/github/bingoohuang/excel2beans/ExcelToBeans.java
@@ -59,12 +59,7 @@ public class ExcelToBeans implements Closeable {
     }
 
     public int getLastCellNum(List<? extends ExcelRowRef> rowRefs, Sheet sheet) {
-        for (val rowRef : rowRefs) {
-            val row = sheet.getRow(rowRef.getRowNum());
-            return row.getLastCellNum();
-        }
-
-        return 0;
+        return rowRefs.isEmpty() ? 0 : sheet.getRow(rowRefs.get(0).getRowNum()).getLastCellNum();
     }
 
     private CellStyle createRedCellStyle() {
fix code smell reported by sonarcloud