/** * Takes in a String representation of a cell reference and fills out the * numeric fields. */ public RefPtg(String cellref) { super(new CellReference(cellref)); }
private static CellReference cr(int rowIx, int colIxAndFlags) { int colIx = colIxAndFlags & 0x00FF; boolean isRowAbs = (colIxAndFlags & 0x8000) == 0; boolean isColAbs = (colIxAndFlags & 0x4000) == 0; return new CellReference(rowIx, colIx, isRowAbs, isColAbs); } }
public CellReference getCellReference() { if (_type != Type.CELL) { throw new IllegalStateException("Not applicable to this type"); } return new CellReference(_rep); }
@Override public String toString() { StringBuffer sb = new StringBuffer(64); CellReference crA = new CellReference(_firstRowIndex, _firstColumnIndex, false, false); CellReference crB = new CellReference(_lastRowIndex, _lastColumnIndex, false, false); sb.append(getClass().getName()); sb.append(" [").append(crA.formatAsString()).append(':').append(crB.formatAsString()).append("]"); return sb.toString(); } }
private CellReference buildCellReference() { String ref = _ctHyperlink.getRef(); if (ref == null) { ref = "A1"; } return new CellReference(ref); }
Sheet sheet = workbook.getSheet("MyInterestingSheet"); CellReference ref = new CellReference("B12"); Row r = sheet.getRow(ref.getRow()); if (r != null) { Cell c = r.getCell(ref.getCol()); }
public CellRangeAddress getArrayFormulaRange() { if (_cellType != CellType.FORMULA) { String ref = new CellReference(this).formatAsString(); throw new IllegalStateException("Cell " + ref + " is not part of an array formula."); } return ((FormulaRecordAggregate)_record).getArrayFormulaRange(); }
/** * Set the column of the first cell that contains the hyperlink * * @param col the 0-based column of the first cell that contains the hyperlink */ @Override public void setFirstColumn(int col) { setCellReference(new CellReference( getFirstRow(), col )); }
/** * Set the row of the first cell that contains the hyperlink * * @param row the 0-based row of the first cell that contains the hyperlink */ @Override public void setFirstRow(int row) { setCellReference(new CellReference( row, getFirstColumn() )); }
private static String getReferencePrintArea(String sheetName, int startC, int endC, int startR, int endR) { //windows excel example: Sheet1!$C$3:$E$4 CellReference colRef = new CellReference(sheetName, startR, startC, true, true); CellReference colRef2 = new CellReference(sheetName, endR, endC, true, true); return "$" + colRef.getCellRefParts()[2] + "$" + colRef.getCellRefParts()[1] + ":$" + colRef2.getCellRefParts()[2] + "$" + colRef2.getCellRefParts()[1]; }
public String toString() { CellReference crA = new CellReference(getFirstRow(), getFirstColumn()); CellReference crB = new CellReference(getLastRow(), getLastColumn()); return getClass().getName() + "[" + crA.formatAsString() + ':' + crB.formatAsString() + "]"; } }
public String toString() { CellReference cr = new CellReference(getRow(), getColumn()); return getClass().getName() + "[" + _evaluator.getSheetNameRange() + '!' + cr.formatAsString() + "]"; } }
public String toString() { CellReference crA = new CellReference(getFirstRow(), getFirstColumn()); CellReference crB = new CellReference(getLastRow(), getLastColumn()); return getClass().getName() + "[" + _evaluator.getSheetNameRange() + '!' + crA.formatAsString() + ':' + crB.formatAsString() + "]"; }
@Override public short getLeftCol() { String cellRef = worksheet.getSheetViews().getSheetViewArray(0).getTopLeftCell(); if(cellRef == null) { return 0; } CellReference cellReference = new CellReference(cellRef); return cellReference.getCol(); }
protected String formatReferenceAsString() { // Only make cell references as needed. Memory is an issue CellReference cr = new CellReference(getRow(), getColumn(), !isRowRelative(), !isColRelative()); return cr.formatAsString(); }
/** * Sets column index of this cell * * @param num column index of this cell */ protected void setCellNum(int num) { checkBounds(num); _cellNum = num; String ref = new CellReference(getRowIndex(), getColumnIndex()).formatAsString(); _cell.setR(ref); }
/** * checks if the given cell is part of the table. Includes checking that they are on the same sheet. * @param cell * @return true if the table and cell are on the same sheet and the cell is within the table range. * @since 3.17 beta 1 * @see #contains(CellReference) (prefered, faster execution and handles undefined cells) */ default boolean contains(Cell cell) { if (cell == null) return false; return contains(new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), true, true)); }
/** * Calls {@link #getRange(Table, CellReference)}. Use that instead for performance. * @param table * @param cell * @return default is unimplemented/null * @see #getRange(Table, CellReference) */ public final CellRangeAddressBase getRange(Table table, Cell cell) { if (cell == null) return null; return getRange(table, new CellReference(cell.getSheet().getSheetName(), cell.getRowIndex(), cell.getColumnIndex(), true, true)); }
protected final String formatReferenceAsString() { CellReference topLeft = new CellReference(getFirstRow(),getFirstColumn(),!isFirstRowRelative(),!isFirstColRelative()); CellReference botRight = new CellReference(getLastRow(),getLastColumn(),!isLastRowRelative(),!isLastColRelative()); if(AreaReference.isWholeColumnReference(SpreadsheetVersion.EXCEL97, topLeft, botRight)) { return (new AreaReference(topLeft, botRight, SpreadsheetVersion.EXCEL97)).formatAsString(); } return topLeft.formatAsString() + ":" + botRight.formatAsString(); }
public void updateCellReferencesForShifting(String msg){ if(isPartOfArrayFormulaGroup()) notifyArrayFormulaChanging(msg); CalculationChain calcChain = getSheet().getWorkbook().getCalculationChain(); int sheetId = (int)getSheet().sheet.getSheetId(); //remove the reference in the calculation chain if(calcChain != null) calcChain.removeItem(sheetId, getReference()); CTCell ctCell = getCTCell(); String r = new CellReference(getRowIndex(), getColumnIndex()).formatAsString(); ctCell.setR(r); }