Пример #1
0
 public override int VisitCell([NotNull] GrammarParser.CellContext context)
 {
     try
     {
         string cellRef = context.GetText();
         int    column  = 0;
         while (65 <= (int)cellRef[column] && (int)cellRef[column] <= 90)
         {
             column++;
         }
         int colNum = ColumnSys26.Sys26ToNum(cellRef.Substring(0, column)) - 1;
         int rowNum = int.Parse(cellRef.Substring(column)) - 1;
         ElectronicTableCell cell = CalculatingCell.Table.Cell(rowNum, colNum);
         if (cell.CurrentlyCalculating)
         {
             var ex = new Exception();
             ex.Data.Add("Type", "cell loop");
             throw ex;
         }
         cell.Depended.Add(CalculatingCell);
         CalculatingCell.Dependecies.Add(cell);
         cell.CurrentlyCalculating = true;
         int ans = cell.Count();
         cell.CurrentlyCalculating = false;
         Console.WriteLine($"Value of {cellRef} is {ans}");
         return(ans);
     }
     catch
     {
         throw;
     }
 }
Пример #2
0
 public void AddColumn(int cnt)
 {
     for (int i = 0; i < cnt; i++)
     {
         DataGridViewColumn col = new DataGridViewColumn(new ElectronicTableCell());
         col.HeaderCell.Value = ColumnSys26.NumToSys26(ColumnCount + 1);
         Columns.Add(col);
     }
 }