public class CellRange extends Object
| Constructor and Description |
|---|
CellRange(com.google.api.services.sheets.v4.model.GridRange gridRange)
Creates a new range based on given Google GridRange.
|
CellRange(int firstRow,
int firstCol,
int lastRow,
int lastCol)
Creates a new sheet-free range based on given row and column indexes.
|
CellRange(String rangeRef)
Creates a new range based on given A1-style string.
|
CellRange(String sheetName,
int firstRow,
int firstCol,
int lastRow,
int lastCol)
Creates a new sheet-based range based on given row and column indexes.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
String |
formatAsRowColString()
Formats this range as string in R1C1-style.
|
String |
formatAsString()
Formats this range as string in A1-style.
|
int |
getColumnsCount()
Gets amount of columns in this range (range width).
|
int |
getFirstCol()
Gets index of the left column of this range.
|
int |
getFirstRow()
Gets index of the top row of this range.
|
int |
getLastCol()
Gets index of the right column of this range.
|
int |
getLastRow()
Gets index of the bottom row of this range.
|
int |
getRowsCount()
Gets amount of rows in this range (range height).
|
String |
getSheetName()
Gets the name of related sheet.
|
int |
hashCode() |
boolean |
intersects(CellRange other)
Determines whether this range intersects with given
CellRange. |
boolean |
isFirstColAbsolute()
Gets whether index of the left column is absolute.
|
boolean |
isFirstRowAbsolute()
Gets whether index of the top row is absolute.
|
boolean |
isInRange(CellRange range)
Determines if the given
CellRange lies within the bounds of this range. |
boolean |
isInRange(CellRef ref)
Determines if the given
CellRef lies within the bounds of this range. |
boolean |
isInRange(int rowInd,
int colInd)
Determines if the given coordinates lie within the bounds of this range.
|
boolean |
isLastColAbsolute()
Gets whether index of the right column is absolute.
|
boolean |
isLastRowAbsolute()
Gets whether index of the bottom row is absolute.
|
boolean |
isSheetNameDefined()
Checks whether related sheet name is defined for this range (sheet-based or not).
|
void |
setFirstCol(int colIndex)
Sets index of the left column for this range.
|
void |
setFirstColAbsolute(boolean colAbs)
Sets index of the left column as absolute.
|
void |
setFirstRow(int rowIndex)
Sets index of the top row for this range.
|
void |
setFirstRowAbsolute(boolean rowAbs)
Sets index of the top row as absolute.
|
void |
setLastCol(int colIndex)
Sets index of the right column for this range.
|
void |
setLastColAbsolute(boolean colAbs)
Sets index of the right column as absolute.
|
void |
setLastRow(int rowIndex)
Sets index of the bottom row for this range.
|
void |
setLastRowAbsolute(boolean rowAbs)
Sets index of the bottom row as absolute.
|
void |
setSheetName(String sheetName)
Sets the name of related sheet and makes this range as sheet-based.
|
String |
toString() |
public CellRange(String rangeRef)
rangeRef - string representation of the range in A1-style. E.g. "A3:G20" or "Sheet1!A3:G20"public CellRange(int firstRow,
int firstCol,
int lastRow,
int lastCol)
firstRow - 0-based index of the top row of the range.firstCol - 0-based index of the left column of the range.lastRow - 0-based index of the bottom row of the range.lastCol - 0-based index of the right column of the range.public CellRange(String sheetName, int firstRow, int firstCol, int lastRow, int lastCol)
sheetName - name of related sheet.firstRow - 0-based index of the top row of the range on related sheet.firstCol - 0-based index of the left column of the range on related sheet.lastRow - 0-based index of the bottom row of the range on related sheet.lastCol - 0-based index of the right column of the range on related sheet.public CellRange(com.google.api.services.sheets.v4.model.GridRange gridRange)
gridRange - the source {@link GridRange) object.public String getSheetName()
null if this range is sheet-free.public void setSheetName(String sheetName)
sheetName - the name of sheet to set.public int getFirstRow()
public void setFirstRow(int rowIndex)
rowIndex - 0-based row index to set.public int getFirstCol()
public void setFirstCol(int colIndex)
colIndex - 0-based column index to set.public int getLastRow()
public void setLastRow(int rowIndex)
rowIndex - 0-based row index to set.public int getLastCol()
public void setLastCol(int colIndex)
colIndex - 0-based column index to set.public boolean isFirstRowAbsolute()
true if index of the top row is absolute or false otherwise.public void setFirstRowAbsolute(boolean rowAbs)
rowAbs - true if index of the top row should be absolute or false otherwise.public boolean isFirstColAbsolute()
true if index of the left column is absolute or false otherwise.public void setFirstColAbsolute(boolean colAbs)
colAbs - true if index of the left column should be absolute or false otherwise.public boolean isLastRowAbsolute()
true if index of the bottom row is absolute or false otherwise.public void setLastRowAbsolute(boolean rowAbs)
rowAbs - true if index of the bottom row should be absolute or false otherwise.public boolean isLastColAbsolute()
true if index of the right column is absolute or false otherwise.public void setLastColAbsolute(boolean colAbs)
colAbs - true if index of the right column should be absolute or false otherwise.public int getColumnsCount()
public int getRowsCount()
public String formatAsString()
public String formatAsRowColString()
public boolean isSheetNameDefined()
true is related sheet name is defined or false otherwise.public boolean isInRange(int rowInd,
int colInd)
rowInd - 0-based row index to check.colInd - 0-based column index to check.true if given coordinates lie within the bounds or false otherwise.public boolean isInRange(CellRef ref)
CellRef lies within the bounds of this range.ref - the cell reference to check.true if given reference lie within the bounds or false otherwise.public boolean isInRange(CellRange range)
CellRange lies within the bounds of this range.range - the cells range to check.true if given range lies within the bounds or false otherwise.public boolean intersects(CellRange other)
CellRange.other - the cells range to check for intersection with this range.true if ranges have at least 1 cell in common or false otherwise.for checking if a single cell intersectsCopyright © 2022. All rights reserved.