Exemplo n.º 1
0
        public ForkedEvaluationCell GetOrCreateUpdatableCell(int rowIndex, int columnIndex)
        {
            RowColKey key = new RowColKey(rowIndex, columnIndex);

            ForkedEvaluationCell result = null;

            if (_sharedCellsByRowCol.ContainsKey(key))
            {
                result = _sharedCellsByRowCol[(key)];
            }
            if (result == null)
            {
                IEvaluationCell mcell = _masterSheet.GetCell(rowIndex, columnIndex);
                if (mcell == null)
                {
                    CellReference cr = new CellReference(rowIndex, columnIndex);
                    throw new InvalidOperationException("Underlying cell '"
                                                        + cr.FormatAsString() + "' is missing in master sheet.");
                }
                result = new ForkedEvaluationCell(this, mcell);
                if (_sharedCellsByRowCol.ContainsKey(key))
                {
                    _sharedCellsByRowCol[key] = result;
                }
                else
                {
                    _sharedCellsByRowCol.Add(key, result);
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        /**
         * Sets the specified cell to the supplied <tt>value</tt>
         * @param sheetName the name of the sheet Containing the cell
         * @param rowIndex zero based
         * @param columnIndex zero based
         */
        public void UpdateCell(String sheetName, int rowIndex, int columnIndex, ValueEval value)
        {
            ForkedEvaluationCell cell = _sewb.GetOrCreateUpdatableCell(sheetName, rowIndex, columnIndex);

            cell.SetValue(value);
            _evaluator.NotifyUpdateCell(cell);
        }
Exemplo n.º 3
0
        public IEvaluationCell GetCell(int rowIndex, int columnIndex)
        {
            RowColKey key = new RowColKey(rowIndex, columnIndex);

            ForkedEvaluationCell result = null;

            if (_sharedCellsByRowCol.ContainsKey(key))
            {
                result = _sharedCellsByRowCol[(key)];
            }

            if (result == null)
            {
                return(_masterSheet.GetCell(rowIndex, columnIndex));
            }
            return(result);
        }
Exemplo n.º 4
0
        public void CopyUpdatedCells(ISheet sheet)
        {
            RowColKey[] keys = new RowColKey[_sharedCellsByRowCol.Count];
            _sharedCellsByRowCol.Keys.CopyTo(keys, 0);
            Array.Sort(keys);
            for (int i = 0; i < keys.Length; i++)
            {
                RowColKey key = keys[i];
                IRow      row = sheet.GetRow(key.RowIndex);
                if (row == null)
                {
                    row = sheet.CreateRow(key.RowIndex);
                }
                ICell destCell = row.GetCell(key.ColumnIndex);
                if (destCell == null)
                {
                    destCell = row.CreateCell(key.ColumnIndex);
                }

                ForkedEvaluationCell srcCell = _sharedCellsByRowCol[(key)];
                srcCell.CopyValue(destCell);
            }
        }