Exemple #1
0
        /// <summary>
        /// Currently a fake loader
        /// </summary>
        public void Load()
        {
            // 3 + RC[-2] + RC[-1]
            RpnExpression expr1 = new RpnExpression();

            expr1.Add(new RpnNodeConst(3.0));
            expr1.Add(new RpnNodeCellRef(0, false, -2, false));
            expr1.Add(new RpnNodeCellRef(0, false, -1, false));
            expr1.Add(new RpnNodeAdd());
            expr1.Add(new RpnNodeAdd());
            _expressions.Add(expr1);

            // RC[-2] + RC[-1]
            RpnExpression expr2 = new RpnExpression();

            expr2.Add(new RpnNodeCellRef(0, false, -2, false));
            expr2.Add(new RpnNodeCellRef(0, false, -1, false));
            expr2.Add(new RpnNodeAdd());
            _expressions.Add(expr2);


            for (int row = 0; row < _numRows; row++)
            {
                for (int col = 0; col < _numCols; col++)
                {
                    // current sheet is 5 columns, 0 to 4.
                    switch (col)
                    {
                    case 3:
                    {
                        FormulaCell cell = new FormulaCell();
                        cell.Formula    = expr1;
                        Cells[row, col] = cell;
                        break;
                    }

                    case 4:
                    {
                        FormulaCell cell = new FormulaCell();
                        cell.Formula    = expr2;
                        Cells[row, col] = cell;
                        break;
                    }

                    default:
                        Cells[row, col]       = new ConstantCell();
                        Cells[row, col].Value = row + col;
                        break;
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Currently a fake loader
        /// </summary>
        public void Load()
        {
            // 3 + RC[-2] + RC[-1]
            RpnExpression expr1 = new RpnExpression();
            expr1.Add(new RpnNodeConst(3.0));
            expr1.Add(new RpnNodeCellRef(0, false, -2, false));
            expr1.Add(new RpnNodeCellRef(0, false, -1, false));
            expr1.Add(new RpnNodeAdd());
            expr1.Add(new RpnNodeAdd());
            _expressions.Add(expr1);

            // RC[-2] + RC[-1]
            RpnExpression expr2 = new RpnExpression();
            expr2.Add(new RpnNodeCellRef(0, false, -2, false));
            expr2.Add(new RpnNodeCellRef(0, false, -1, false));
            expr2.Add(new RpnNodeAdd());
            _expressions.Add(expr2);

            for (int row = 0; row < _numRows; row++)
            {
                for (int col = 0; col < _numCols; col++)
                {
                    // current sheet is 5 columns, 0 to 4.
                    switch (col)
                    {
                        case 3:
                        {
                            FormulaCell cell = new FormulaCell();
                            cell.Formula = expr1;
                            Cells[row, col] = cell;
                            break;
                        }

                        case 4:
                        {
                            FormulaCell cell = new FormulaCell();
                            cell.Formula = expr2;
                            Cells[row, col] = cell;
                            break;
                        }

                        default:
                            Cells[row, col] = new ConstantCell();
                            Cells[row, col].Value = row + col;
                            break;
                    }
                }
            }
        }