/** * This formula was copied from a formula already present in the writable * workbook. Requires special handling to sort out the cell references * * @param ws the workbook settings * @param es the external sheet * @param nt the name table */ private void initializeCopiedFormula(WorkbookSettings ws, ExternalSheet es, WorkbookMethods nt) { try { parser = new FormulaParser(formulaBytes, this, es, nt, ws); parser.parse(); parser.adjustRelativeCellReferences (getColumn() - copiedFrom.getColumn(), getRow() - copiedFrom.getRow()); formulaString = parser.getFormula(); formulaBytes = parser.getBytes(); } catch (FormulaException e) { try { // try again, with an error formula formulaToParse = "ERROR(1)"; parser = new FormulaParser(formulaToParse, es, nt, ws); parser.parse(); formulaString = parser.getFormula(); formulaBytes = parser.getBytes(); } catch (FormulaException e2) { // fail silently //logger.error(string.Empty, e2); } } }
/** * Adds a cell to this row, growing the array of cells as required * * @param cv the cell to add */ public void addCell(CellValue cv) { int col = cv.getColumn(); if (col >= maxColumns) { //logger.warn("Could not add cell at " + // CellReferenceHelper.getCellReference(cv.getRow(), // cv.getColumn()) + // " because it exceeds the maximum column limit"); return; } // Grow the array if needs be if (col >= cells.Length) { CellValue[] oldCells = cells; cells = new CellValue[System.Math.Max(oldCells.Length + growSize, col + 1)]; System.Array.Copy(oldCells, 0, cells, 0, oldCells.Length); oldCells = null; } // Remove any cell features from the cell being replaced if (cells[col] != null) { WritableCellFeatures wcf = cells[col].getWritableCellFeatures(); if (wcf != null) { wcf.removeComment(); // if the cell is part of a shared data validation,then don't remove // the validation if (wcf.getDVParser() != null && !wcf.getDVParser().extendedCellsValidation()) { wcf.removeDataValidation(); } } } cells[col] = cv; numColumns = System.Math.Max(col + 1, numColumns); }
/** * Adds a cell to this row, growing the array of cells as required * * @param cv the cell to add */ public void addCell(CellValue cv) { int col = cv.getColumn(); if (col >= maxColumns) { //logger.warn("Could not add cell at " + // CellReferenceHelper.getCellReference(cv.getRow(), // cv.getColumn()) + // " because it exceeds the maximum column limit"); return; } // Grow the array if needs be if (col >= cells.Length) { CellValue[] oldCells = cells; cells = new CellValue[System.Math.Max(oldCells.Length + growSize, col + 1)]; System.Array.Copy(oldCells, 0, cells, 0, oldCells.Length); oldCells = null; } // Remove any cell features from the cell being replaced if (cells[col] != null) { WritableCellFeatures wcf = cells[col].getWritableCellFeatures(); if (wcf != null) { wcf.removeComment(); // if the cell is part of a shared data validation,then don't remove // the validation if (wcf.getDVParser() != null && !wcf.getDVParser().extendedCellsValidation()) { wcf.removeDataValidation(); } } } cells[col] = cv; numColumns = System.Math.Max(col + 1, numColumns); }