public ICell GetCell(int cellnum, MissingCellPolicy policy) { CheckBounds(cellnum); SXSSFCell cell = null; if (_cells.ContainsKey(cellnum)) { cell = _cells[cellnum]; } switch (policy) { case MissingCellPolicy.RETURN_NULL_AND_BLANK: return(cell); case MissingCellPolicy.RETURN_BLANK_AS_NULL: bool isBlank = (cell != null && cell.CellType == CellType.Blank); return((isBlank) ? null : cell); case MissingCellPolicy.CREATE_NULL_AS_BLANK: return((cell == null) ? CreateCell(cellnum, CellType.Blank) : cell); default: throw new ArgumentException("Illegal policy " + policy + " (" + policy + ")"); } }
public ICell CreateCell(int column, CellType type) { CheckBounds(column); SXSSFCell cell = new SXSSFCell(this, type); _cells[column] = cell; return(cell); }
/** * Return the column number of a cell if it is in this row * Otherwise return -1 * * @param cell the cell to get the index of * @return cell column index if it is in this row, -1 otherwise */ /*package*/ public int GetCellIndex(SXSSFCell cell) { foreach (var entry in _cells) { if (entry.Value == cell) { return(entry.Key); } } return(-1); }
public void TestEvaluateSimple() { SXSSFWorkbook wb = new SXSSFWorkbook(5); SXSSFSheet s = wb.CreateSheet() as SXSSFSheet; IFormulaEvaluator eval = wb.GetCreationHelper().CreateFormulaEvaluator(); SXSSFCell c = s.CreateRow(0).CreateCell(0) as SXSSFCell; c.CellFormula = (/*setter*/ "1+2"); Assert.AreEqual(0, (int)c.NumericCellValue); eval.EvaluateFormulaCell(c); Assert.AreEqual(3, (int)c.NumericCellValue); c = s.CreateRow(1).CreateCell(0) as SXSSFCell; c.CellFormula = (/*setter*/ "CONCATENATE(\"hello\",\" \",\"world\")"); eval.EvaluateFormulaCell(c); Assert.AreEqual("hello world", c.StringCellValue); }
public SXSSFEvaluationCell getCell(int rowIndex, int columnIndex) { SXSSFRow row = _xs._rows[rowIndex]; if (row == null) { if (rowIndex <= _xs.lastFlushedRowNumber) { throw new RowFlushedException(rowIndex); } return(null); } SXSSFCell cell = (SXSSFCell)row.Cells[columnIndex]; if (cell == null) { return(null); } return(new SXSSFEvaluationCell(cell, this)); }
public IEvaluationCell GetCell(int rowIndex, int columnIndex) { SXSSFRow row = (SXSSFRow)_xs.GetRow(rowIndex); if (row == null) { if (rowIndex <= _xs.LastFlushedRowNumber) { throw new RowFlushedException(rowIndex); } return(null); } SXSSFCell cell = (SXSSFCell)row.GetCell(columnIndex); if (cell == null) { return(null); } return(new SXSSFEvaluationCell(cell, this)); }
public void TestEvaluateRefInsideWindow() { SXSSFWorkbook wb = new SXSSFWorkbook(5); SXSSFSheet s = wb.CreateSheet() as SXSSFSheet; IFormulaEvaluator eval = wb.GetCreationHelper().CreateFormulaEvaluator(); SXSSFCell c = s.CreateRow(0).CreateCell(0) as SXSSFCell; c.SetCellValue(1.5); c = s.CreateRow(1).CreateCell(0) as SXSSFCell; c.CellFormula = (/*setter*/ "A1*2"); Assert.AreEqual(0, (int)c.NumericCellValue); eval.EvaluateFormulaCell(c); Assert.AreEqual(3, (int)c.NumericCellValue); wb.Close(); }
public SXSSFEvaluationCell(SXSSFCell cell) : this(cell, new SXSSFEvaluationSheet(cell.Sheet as SXSSFSheet)) { }
public SXSSFEvaluationCell(SXSSFCell cell, SXSSFEvaluationSheet evaluationSheet) { _cell = cell; _evalSheet = evaluationSheet; }
public Ptg[] getFormulaTokens(SXSSFEvaluationCell evalCell) { SXSSFCell cell = ((SXSSFEvaluationCell)evalCell).getSXSSFCell(); return(FormulaParser.Parse(cell.CellFormula, this, FormulaType.Cell, _uBook.GetSheetIndex(cell.Sheet))); }
public SXSSFEvaluationCell(SXSSFCell cell) : this(cell, null /*new SXSSFEvaluationSheet(cell.Sheet)*/) { throw new NotImplementedException(); }