Skip to content

Commit

Permalink
added new helper methods
Browse files Browse the repository at this point in the history
Issue #165
  • Loading branch information
rsoika committed Nov 18, 2024
1 parent 1b8be92 commit 333db24
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,24 @@ public static void insertColumn(XSSFSheet sheet, int startColumn, int endColumn)
}
}

/**
* Resolves column and row number into a excel reference.
*
* @param col
* @param row
* @return
*/
public static String getCellReference(int col, int row) {
// convert column into letters
StringBuilder colRef = new StringBuilder();
int temp = col;
while (temp >= 0) {
int remainder = temp % 26;
colRef.insert(0, (char) (65 + remainder)); // 65 ASCII for 'A'
temp = (temp / 26) - 1;
}
// append row number starting at 1
return colRef.toString() + (row + 1);
}

}

0 comments on commit 333db24

Please sign in to comment.