You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* A class to get references to cells for use in formulas
27
27
*
28
28
* @author James Kleeh
29
-
* @since1.0.0
29
+
* @since0.1.0
30
30
*/
31
31
@CompileStatic
32
32
classFormula {
@@ -39,10 +39,16 @@ class Formula {
39
39
this.columnIndexes = columnIndexes
40
40
}
41
41
42
+
/**
43
+
* @return The current row number (1 based)
44
+
*/
42
45
intgetRow() {
43
46
cell.rowIndex +1
44
47
}
45
48
49
+
/**
50
+
* @return The current column (A..Z)
51
+
*/
46
52
StringgetColumn() {
47
53
relativeColumn(0)
48
54
}
@@ -67,21 +73,48 @@ class Formula {
67
73
}
68
74
}
69
75
76
+
/**
77
+
* Retrieves a cell relative to the current cell. Use negative values to reference rows and columns before the current cell and positive values to reference rows and columns after the current cell.
* Retrieves a cell relative to the current cell. Use negative values to reference previous columns and positive values to reference columns after the current cell.
89
+
*
90
+
* @param columnIndex The column index
91
+
* @return A cell relative to the current cell
92
+
*/
74
93
StringrelativeCell(intcolumnIndex) {
75
94
relativeCell(columnIndex, 0)
76
95
}
77
96
97
+
/**
98
+
* Retrieves an exact cell reference
99
+
*
100
+
* @param columnIndex The column index
101
+
* @param rowIndex The row index
102
+
* @return The desired cell
103
+
*/
78
104
StringexactCell(intcolumnIndex, introwIndex) {
79
105
if (rowIndex <0) {
80
106
thrownewIllegalArgumentException("An invalid row index of $rowIndex was specified")
81
107
}
82
108
exactColumn(columnIndex) + (rowIndex +1)
83
109
}
84
110
111
+
/**
112
+
* Retrieves an exact cell reference based on a previously defined column definition (created by {@link com.jameskleeh.excel.internal.CreatesCells#column} and row index
113
+
*
114
+
* @param columnName The column identifier
115
+
* @param rowIndex The row index
116
+
* @return The desired cell
117
+
*/
85
118
StringexactCell(StringcolumnName, introwIndex) {
86
119
if (columnIndexes && columnIndexes.containsKey(columnName)) {
87
120
exactCell(columnIndexes[columnName], rowIndex)
@@ -90,6 +123,12 @@ class Formula {
90
123
}
91
124
}
92
125
126
+
/**
127
+
* Retrieves an exact cell reference based on a previously defined column definition (created by {@link com.jameskleeh.excel.internal.CreatesCells#column}
0 commit comments