Exemplo n.º 1
0
		public static void Main()
		{
            Spreadsheet.Spreadsheets = new SpreadsheetsDictionary();
		    var spreadsheetsDictionary = new SpreadsheetDictionary();
            Spreadsheet.Spreadsheets.Add(0, spreadsheetsDictionary);
		    var row = new RowDictionary();
            spreadsheetsDictionary.Add(0, row);

		    var cellA1 = new Cell(0, 0, 0);
		    cellA1.Value = "250";
		    var cellB1 = new Cell(0, 0, 1);
            cellB1.Value = "250";
		    var cellC1 = new Cell(0, 0, 2);
            cellC1.Formula = "800 - SUM(A1:B1) + 100";
		    cellC1.HasFormula = true;

            row.Add(0, cellA1);
            row.Add(1, cellB1);
            row.Add(2, cellC1);

            //var spreadsheet = new Spreadsheet();
		    //spreadsheet.Calc();

		    var parsedCell = Spreadsheet.Spreadsheets[0][0][2];
		    var value = parsedCell.UpdateValue();
		    value = value;
		}
Exemplo n.º 2
0
		public static Expression UpdateCellValue(Cell cell)
        {
            if (cell.HasFormula && cell.State.Count < 1)
            {
                cell.State.Push("Parsing");
				cell.CalcCount++;
				cell.CalcLast = CalcLast;
                var formula = new Formula();
                var value = formula.Parse(cell.Formula);
                cell.State.Pop();
                return value;
            }
            return cell.Exp;
        }