@Test public void testGetColumnName() { Assert.assertEquals(columnName, CellCoordinate.getColumnName(columnIndexCheck)); String[] names = new String[columnIndexCheck]; Arrays.fill(names, "Foo"); Assert.assertEquals(columnName, CellCoordinate.getColumnName(columnIndexCheck, 0, names)); names = new String[columnIndexCheck + 1]; Arrays.fill(names, "Foo"); Assert.assertEquals("Foo", CellCoordinate.getColumnName(columnIndexCheck, 0, names)); Assert.assertEquals("Foo", CellCoordinate.getColumnName(columnIndexCheck, columnIndexCheck, names)); }
public static String getColumnName(int columnIndex) { String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; StringBuilder columnName = new StringBuilder(); int index = columnIndex; int overflowIndex = -1; while (index > 25) { overflowIndex++; index -= 26; } if (overflowIndex >= 0) { columnName.append(alphabet.toCharArray()[overflowIndex]); } columnName.append(alphabet.toCharArray()[index]); return columnName.toString(); }
CellCoordinate { public static String getColumnName(int columnIndex) { String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; StringBuilder columnName = new StringBuilder(); int index = columnIndex; int overflowIndex = -1; while (index > 25) { overflowIndex++; index -= 26; } if (overflowIndex >= 0) { columnName.append(alphabet.toCharArray()[overflowIndex]); } columnName.append(alphabet.toCharArray()[index]); return columnName.toString(); } }
CellCoordinate { public static String getColumnName(int columnIndex) { String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; StringBuilder columnName = new StringBuilder(); int index = columnIndex; int overflowIndex = -1; while (index > 25) { overflowIndex++; index -= 26; } if (overflowIndex >= 0) { columnName.append(alphabet.toCharArray()[overflowIndex]); } columnName.append(alphabet.toCharArray()[index]); return columnName.toString(); } CellCoordinate(); }
CellCoordinate { public static String getColumnName(int columnIndex) { String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; StringBuilder columnName = new StringBuilder(); int index = columnIndex; int overflowIndex = -1; while (index > 25) { overflowIndex++; index -= 26; } if (overflowIndex >= 0) { columnName.append(alphabet.toCharArray()[overflowIndex]); } columnName.append(alphabet.toCharArray()[index]); return columnName.toString(); } CellCoordinate(); static CellCoordinate fromCellId(String cellId); static String getColumnName(int columnIndex); static String getColumnName(int columnIndex, int columnStartIndex, String ... columnNames); int getRowIndex(); void setRowIndex(int rowIndex); int getColumnIndex(); void setColumnIndex(int columnIndex); }
CellCoordinate { public static String getColumnName(int columnIndex) { String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; StringBuilder columnName = new StringBuilder(); int index = columnIndex; int overflowIndex = -1; while (index > 25) { overflowIndex++; index -= 26; } if (overflowIndex >= 0) { columnName.append(alphabet.toCharArray()[overflowIndex]); } columnName.append(alphabet.toCharArray()[index]); return columnName.toString(); } CellCoordinate(); static CellCoordinate fromCellId(String cellId); static String getColumnName(int columnIndex); static String getColumnName(int columnIndex, int columnStartIndex, String ... columnNames); int getRowIndex(); void setRowIndex(int rowIndex); int getColumnIndex(); void setColumnIndex(int columnIndex);  }