/** * Construct a XSSFRow. * * @param row the xml bean containing all cell definitions for this row. * @param sheet the parent sheet. */ protected XSSFRow(CTRow row, XSSFSheet sheet) { _row = row; _sheet = sheet; _cells = new TreeMap<Integer, XSSFCell>(); for (CTCell c : row.getCArray()) { XSSFCell cell = new XSSFCell(this, c); _cells.put(cell.getColumnIndex(), cell); sheet.onReadCell(cell); } }
/** * update cell references when shifting rows * * @param n the number of rows to move */ protected void shift(int n) { int rownum = getRowNum() + n; CalculationChain calcChain = _sheet.getWorkbook().getCalculationChain(); int sheetId = (int) _sheet.sheet.getSheetId(); String msg = "Row[rownum=" + getRowNum() + "] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for (Cell c : this) { XSSFCell cell = (XSSFCell) c; if (cell.isPartOfArrayFormulaGroup()) { cell.notifyArrayFormulaChanging(msg); } // remove the reference in the calculation chain if (calcChain != null) calcChain.removeItem(sheetId, cell.getReference()); CTCell ctCell = cell.getCTCell(); String r = new CellReference(rownum, cell.getColumnIndex()).formatAsString(); ctCell.setR(r); } setRowNum(rownum); }