Ejemplo n.º 1
0
        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 + ")");
            }
        }
Ejemplo n.º 2
0
        public ICell CreateCell(int column, CellType type)
        {
            CheckBounds(column);
            SXSSFCell cell = new SXSSFCell(this, type);

            _cells[column] = cell;
            return(cell);
        }
Ejemplo n.º 3
0
 /**
  * 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);
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
 public SXSSFEvaluationCell(SXSSFCell cell)
     : this(cell, new SXSSFEvaluationSheet(cell.Sheet as SXSSFSheet))
 {
 }
Ejemplo n.º 9
0
 public SXSSFEvaluationCell(SXSSFCell cell, SXSSFEvaluationSheet evaluationSheet)
 {
     _cell      = cell;
     _evalSheet = evaluationSheet;
 }
Ejemplo n.º 10
0
        public Ptg[] getFormulaTokens(SXSSFEvaluationCell evalCell)
        {
            SXSSFCell cell = ((SXSSFEvaluationCell)evalCell).getSXSSFCell();

            return(FormulaParser.Parse(cell.CellFormula, this, FormulaType.Cell, _uBook.GetSheetIndex(cell.Sheet)));
        }
Ejemplo n.º 11
0
 public SXSSFEvaluationCell(SXSSFCell cell) : this(cell, null /*new SXSSFEvaluationSheet(cell.Sheet)*/)
 {
     throw new NotImplementedException();
 }