Class CellInfo
public final class CellInfo
extends Object
Provides helper functions for converting between cell addresses and row/column indices.
This utility class offers static methods to convert row indices to names, column indices to names, cell indices to addresses, and vice versa. It also supports retrieving the pixel boundary of a given range.
// Convert cell index (row=2, column=1) to name -> "B3"
String cellName = CellInfo.CellIndexToName(2, 1);
// Convert cell name to index -> [2, 1]
int[] index = CellInfo.CellNameToIndex("B3");
// Convert column index to name -> "D"
String colName = CellInfo.ColumnIndexToName(3);
// Convert row index to name -> "5"
String rowName = CellInfo.RowIndexToName(4);
Constructor Summary
Constructors
Method Summary
All Methods Static Methods Concrete Methods
Gets cell name(address) according to its row and column indexes.
static int[]
Gets cell row and column according to its name(address).
Gets column name according to column index.
static int
Gets column index according to column name.
Gets the position and size (in pixels) of the specified range.
Gets row name according to row index.
static int
Gets row index according to row name.
Methods inherited from class java.lang.Object
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
Constructor Details
CellInfo
public CellInfo ()
Method Details
RowIndexToName
public static String RowIndexToName (int index)
Gets row name according to row index.
String rowName = CellInfo.RowIndexToName(4);
Parameters:
index - row index
Returns:
the name of row
RowNameToIndex
public static int RowNameToIndex (String name)
Gets row index according to row name.
int rowIndex = CellInfo.RowNameToIndex("5");
Parameters:
name - row name
Returns:
the index of row
ColumnIndexToName
public static String ColumnIndexToName (int index)
Gets column name according to column index.
String columnName = CellInfo.ColumnIndexToName(3);
Parameters:
index - column index
Returns:
the name of column
ColumnNameToIndex
public static int ColumnNameToIndex (String name)
Gets column index according to column name.
int columnIndex = CellInfo.ColumnNameToIndex("D");
Parameters:
name - column name
Returns:
the index of column
CellIndexToName
public static String CellIndexToName (int row,
int column)
Gets cell name(address) according to its row and column indexes.
String cellName = CellInfo.CellIndexToName(2, 1);
Parameters:
row - row index
column - column index
Returns:
the address of cell
CellNameToIndex
public static int[] CellNameToIndex (String name)
Gets cell row and column according to its name(address).
int[] index = CellInfo.CellNameToIndex("B3");
Parameters:
name - cell name
Returns:
a array containing the converted row and column index
GetRangeBoundary
Gets the position and size (in pixels) of the specified range.
Rectangle boundary = CellInfo.GetRangeBoundary(worksheet.getRange("A1:B2"));
Parameters:
range - The range object
Returns:
a rectangle containing the position and size of the range