/// <summary> /// Writes the given contents to a specified cell location. /// </summary> private void SetCell(int row, int col, string cellVal) { string cellName = GetCellName(col, row); HashSet <string> auxCells = new HashSet <string>(ss1.getDependentCells(cellName)); ss1.SetContentsOfCell(cellName, cellVal); //if the result is a formula error display a formula error message, otherwise set the cell with the result. Type a = ss1.GetCellValue(cellName).GetType(); if (ss1.GetCellValue(cellName).GetType() == typeof(FormulaError)) { FormulaError error = (FormulaError)ss1.GetCellValue(cellName); if (error.Reason == "Circular dependency") { spreadsheetPanel1.SetValue(col, row, "#REF"); } else { spreadsheetPanel1.SetValue(col, row, "Formula Error!"); } } else { spreadsheetPanel1.SetValue(col, row, ss1.GetCellValue(cellName).ToString()); UpdateCells(new HashSet <string>(ss1.getDependentCells(cellName))); } UpdateCells(auxCells); }