[]
CloneableA Reference describes a cell, a range, a worksheet-qualified reference, a 3D worksheet reference, or a reference to an external workbook. Use its row, column, range, worksheet, and workbook properties to build or inspect formula references programmatically.
If a row or column index is relative, use the base row or base column in the parse or unparse context when converting the reference to text.
FormulaSyntaxTree syntaxTree = FormulaSyntaxTree.Parse("SUM(Sheet1:Sheet3!D4:G10)");
FunctionNode functionNode = (FunctionNode) syntaxTree.getRoot();
ReferenceNode referenceNode = (ReferenceNode) functionNode.getChildren().get(0);
Reference reference = referenceNode.getReference();
reference.setLastWorksheetName(null);
Reference addedReference = new Reference();
addedReference.setRow(1);
addedReference.setColumn(1);
functionNode.getChildren().add(new ReferenceNode(addedReference));
String formulaText = syntaxTree.toString();
clone()booleanReference instance for equality.booleanintbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanintintintgetRow()inthashCode()voidsetColumn(int value) voidsetHasColumn(boolean value) voidsetHasRow(boolean value) voidsetIsColumnRelative(boolean value) voidsetIsError(boolean value) voidsetIsLastColumnRelative(boolean value) voidsetIsLastRowRelative(boolean value) voidsetIsRange(boolean value) voidsetIsRowRelative(boolean value) voidsetLastColumn(int value) voidsetLastRow(int value) voidsetLastWorksheetName(String value) voidsetRow(int value) voidsetWorkbook(WorkbookReference value) voidsetWorksheetName(String value) toString()toString(UnParseContext context) Use this method to retrieve the workbook component of an external reference, such as a reference that points to a worksheet in another workbook. The default value is null.
Reference reference = new Reference();
reference.setWorkbook(WorkbookReference.FromName("Book1"));
WorkbookReference workbookReference = reference.getWorkbook();
null if this reference does not specify an external workbook.Use this method to associate this reference with an external workbook when building or modifying a formula reference. Set this property to null to clear the external workbook reference. The default value is null.
Reference reference = new Reference();
reference.setWorkbook(WorkbookReference.FromName("Book1"));
value - The external workbook reference to associate with this reference, or null to remove the external workbook reference.Use this method to retrieve the start worksheet name associated with this reference. For a 3D reference, use setLastWorksheetName(String) to set the end worksheet name.
Reference reference = new Reference();
reference.setWorksheetName("Sheet1");
String worksheetName = reference.getWorksheetName();
null if no worksheet name has been set.Use this method to set or update the start worksheet name associated with this reference. For a 3D reference, use setLastWorksheetName(String) to set or update the end worksheet name.
Reference reference = new Reference();
reference.setWorksheetName("Sheet1");
value - The worksheet name, or null if no worksheet name should be set.Use this method together with setWorksheetName(String) to update the worksheet span represented by a 3D reference.
Reference reference = new Reference();
reference.setWorksheetName("Sheet1");
reference.setLastWorksheetName("Sheet3");
String lastWorksheetName = reference.getLastWorksheetName();
null if no end worksheet name has been specified.Use this method together with getWorksheetName() to inspect the worksheet span represented by a 3D reference.
Reference reference = new Reference();
reference.setWorksheetName("Sheet1");
reference.setLastWorksheetName("Sheet3");
value - The name of the end worksheet of the 3D reference, or null if no end worksheet name has been specified.This property indicates whether the reference contains row information. The default value is true. If the reference is in an error state, this method returns false.
Reference reference = new Reference();
reference.setHasRow(false);
boolean hasRow = reference.getHasRow();
true if the reference includes a row part; otherwise, false. Returns false if the reference contains an error.This property indicates whether the reference contains row information. The default value is true. If the reference is in an error state, this method sets false.
Reference reference = new Reference();
reference.setHasRow(false);
value - true if the reference includes a row part; otherwise, false. Sets false if the reference contains an error.This property indicates whether the reference contains column information. The default value is true. If the reference is in an error state, this method returns false.
Reference reference = new Reference();
reference.setHasColumn(false);
boolean hasColumn = reference.getHasColumn();
true if the reference includes a column part; otherwise, false. Returns false if the reference contains an error.This property indicates whether the reference contains column information. The default value is true. If the reference is in an error state, this method sets false.
Reference reference = new Reference();
reference.setHasColumn(false);
value - true if the reference includes a column part; otherwise, false. Sets false if the reference contains an error.The default value is 0. If this reference does not have a row, as indicated by getHasRow(), this method returns 0.
Reference reference = new Reference();
reference.setRow(3);
int row = reference.getRow();
The default value is 0. If this reference does not have a row, as indicated by getHasRow(), this method sets 0.
Reference reference = new Reference();
reference.setRow(3);
value - The 0-based row index. sets 0 if the reference does not have a row.Returns the column index stored in this reference. The default value is 0. If getHasColumn() returns false, this method returns 0.
Reference reference = new Reference();
reference.setColumn(2);
int column = reference.getColumn();
0 if this reference does not have a column.sets the column index stored in this reference. The default value is 0. If getHasColumn() sets false, this method sets 0.
Reference reference = new Reference();
reference.setColumn(2);
value - The 0-based column index, or 0 if this reference does not have a column.For a range reference, this method returns the last row stored in the reference. If the reference is not a range, it returns the value of getRow(). If the reference is a range that does not contain row information, it returns the maximum row index.
Reference reference = new Reference();
reference.setIsRange(true);
reference.setLastRow(5);
int lastRow = reference.getLastRow();
getRow() when the reference is not a range.For a range reference, this method sets the last row stored in the reference. If the reference is not a range, it sets the value of getRow(). If the reference is a range that does not contain row information, it sets the maximum row index.
Reference reference = new Reference();
reference.setIsRange(true);
reference.setLastRow(5);
value - The 0-based end row index. sets getRow() when the reference is not a range.If getIsRange() returns true, this method returns the last column index of the range when getHasColumn() is true; otherwise, it returns the last worksheet column index. If this reference does not represent a range, this method returns the same value as getColumn(). The default value is 0.
Reference reference = new Reference();
reference.setColumn(1);
reference.setLastColumn(3);
int lastColumn = reference.getLastColumn();
If getIsRange() sets true, this method sets the last column index of the range when getHasColumn() is true; otherwise, it sets the last worksheet column index. If this reference does not represent a range, this method sets the same value as getColumn(). The default value is 0.
Reference reference = new Reference();
reference.setColumn(1);
reference.setLastColumn(3);
value - The 0-based end column index. For a non-range reference, this is the same as the start column index.This property indicates whether the row is stored as a relative reference rather than an absolute one. The default value is true. If this reference contains an error, this method returns false.
Reference reference = new Reference();
reference.setRow(2);
reference.setIsRowRelative(false);
boolean isRowRelative = reference.getIsRowRelative();
true if the row part of the reference is relative; false if it is absolute or if this reference contains an error.This property indicates whether the row is stored as a relative reference rather than an absolute one. The default value is true. If this reference contains an error, this method sets false.
Reference reference = new Reference();
reference.setRow(2);
reference.setIsRowRelative(false);
value - true if the row part of the reference is relative; false if it is absolute or if this reference contains an error.This property indicates whether the column is stored as a relative reference rather than an absolute one. The default value is true. If this reference contains an error, this method returns false.
Reference reference = new Reference();
reference.setColumn(1);
reference.setIsColumnRelative(false);
boolean isColumnRelative = reference.getIsColumnRelative();
true if the column part of the reference is relative; false if it is absolute or if this reference contains an error.This property indicates whether the column is stored as a relative reference rather than an absolute one. The default value is true. If this reference contains an error, this method sets false.
Reference reference = new Reference();
reference.setColumn(1);
reference.setIsColumnRelative(false);
value - true if the column part of the reference is relative; false if it is absolute or if this reference contains an error.For a range reference, this method indicates whether the ending row is stored as a relative row reference. For a non-range reference, it returns the same value as getIsRowRelative(). If the reference contains an error, this method returns false.
Reference reference = new Reference();
reference.setLastRow(1);
reference.setIsLastRowRelative(false);
boolean isLastRowRelative = reference.getIsLastRowRelative();
true if the last row is relative; otherwise, false. Returns false if the reference contains an error.For a range reference, this method indicates whether the ending row is stored as a relative row reference. For a non-range reference, it sets the same value as getIsRowRelative(). If the reference contains an error, this method sets false.
Reference reference = new Reference();
reference.setLastRow(1);
reference.setIsLastRowRelative(false);
value - true if the last row is relative; otherwise, false. sets false if the reference contains an error.For a range reference, this method returns whether the end column is stored as a relative reference. For a non-range reference, it returns the same value as getIsColumnRelative(). The default value is true. If this reference contains an error, this method returns false.
Reference reference = new Reference();
reference.setColumn(0);
reference.setLastColumn(1);
reference.setIsLastColumnRelative(false);
boolean isLastColumnRelative = reference.getIsLastColumnRelative();
true if the last column part is relative; otherwise, false. Returns false if this reference contains an error.For a range reference, this method sets whether the end column is stored as a relative reference. For a non-range reference, it sets the same value as getIsColumnRelative(). The default value is true. If this reference contains an error, this method sets false.
Reference reference = new Reference();
reference.setColumn(0);
reference.setLastColumn(1);
reference.setIsLastColumnRelative(false);
value - true if the last column part is relative; otherwise, false. Sets false if this reference contains an error.The default value is false. This method returns true when the reference has the range attribute set. If the reference contains an error, this method returns false.
Reference reference = new Reference();
reference.setLastColumn(1);
boolean isRange = reference.getIsRange();
true if this reference represents a range; otherwise, false.The default value is false. This method sets true when the reference has the range attribute set. If the reference contains an error, this method sets false.
Reference reference = new Reference();
reference.setLastColumn(1);
reference.setIsRange(true);
value - true if this reference represents a range; otherwise, false.The default value is false. This method returns true when the reference has the error flag, when the worksheet name is "#REF", or when the reference points to an external workbook without a worksheet name.
Reference reference = new Reference();
reference.setIsError(true);
boolean isError = reference.getIsError();
true if the reference contains an error; otherwise, false.The default value is false. This method sets true when the reference has the error flag, when the worksheet name is "#REF", or when the reference points to an external workbook without a worksheet name.
Reference reference = new Reference();
reference.setIsError(true);
value - true if the reference contains an error; otherwise, false.Use UnParseContext to control how the reference is converted, including whether the result uses A1 or R1C1 notation and which base row and base column are applied when relative references are resolved.
Reference reference = new Reference();
reference.setRow(1);
reference.setColumn(2);
UnParseContext context = new UnParseContext();
context.setIsR1C1(true);
String text = reference.toString(context);
context - The context that specifies how the reference is converted. Must not be null.context.NullPointerException - if context is null.If obj is a Reference, this method compares it by using equals(Reference). If obj is null or is not a Reference, this method returns false.
Reference instance for equality.This method compares the reference kind and the corresponding reference attributes, such as row, column, range bounds, worksheet names, and workbook reference, when those parts are present in the reference. If both references represent an error reference, this method returns true.
Use equals(Object) when comparing through late binding.
other - The reference to compare with. Must not be null.true if the specified reference is equal to this reference; otherwise, false.NullPointerException - if other is null.This implementation does not derive the hash code from the current state of the reference. Because all reference fields are mutable, it always returns the hash code of Reference itself.
The returned Reference contains the same reference settings as this instance, including workbook, worksheet, row, column, and kind information. This method performs a shallow copy.