/** * If cell Contains a formula, the formula is Evaluated and returned, * else the CellValue simply copies the appropriate cell value from * the cell and also its cell type. This method should be preferred over * EvaluateInCell() when the call should not modify the contents of the * original cell. * * @param sheetName the name of the sheet Containing the cell * @param rowIndex zero based * @param columnIndex zero based * @return <code>null</code> if the supplied cell is <code>null</code> or blank */ public ValueEval Evaluate(String sheetName, int rowIndex, int columnIndex) { IEvaluationCell cell = _sewb.GetEvaluationCell(sheetName, rowIndex, columnIndex); switch (cell.CellType) { case CellType.Boolean: return(BoolEval.ValueOf(cell.BooleanCellValue)); case CellType.Error: return(ErrorEval.ValueOf(cell.ErrorCellValue)); case CellType.Formula: return(_evaluator.Evaluate(cell)); case CellType.Numeric: return(new NumberEval(cell.NumericCellValue)); case CellType.String: return(new StringEval(cell.StringCellValue)); case CellType.Blank: return(null); } throw new InvalidOperationException("Bad cell type (" + cell.CellType + ")"); }
/** * If cell Contains a formula, the formula is Evaluated and returned, * else the CellValue simply copies the appropriate cell value from * the cell and also its cell type. This method should be preferred over * EvaluateInCell() when the call should not modify the contents of the * original cell. * * @param sheetName the name of the sheet Containing the cell * @param rowIndex zero based * @param columnIndex zero based * @return <code>null</code> if the supplied cell is <code>null</code> or blank */ public ValueEval Evaluate(String sheetName, int rowIndex, int columnIndex) { IEvaluationCell cell = _sewb.GetEvaluationCell(sheetName, rowIndex, columnIndex); switch (cell.CellType) { case CellType.BOOLEAN: return(BoolEval.ValueOf(cell.BooleanCellValue)); case CellType.ERROR: return(ErrorEval.ValueOf(cell.ErrorCellValue)); case CellType.FORMULA: return(_evaluator.Evaluate(cell)); case CellType.NUMERIC: return(new NumberEval(cell.NumericCellValue)); case CellType.STRING: return(new StringEval(cell.StringCellValue)); case CellType.BLANK: return(null); } throw new InvalidOperationException("Bad cell type (" + cell.CellType + ")"); }