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); }
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); }
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); } }
public ActionResult QueryTimeTableIndex(string sno) { string number = null; string[,] timeTable = new string[13, 5]; for (int i = 0; i < 13; i++) { for (int j = 0; j < 5; j++) { timeTable[i, j] = "0"; } } SelectedCourseDBContext selectedcourse = new SelectedCourseDBContext(); List <SelectedCourse> selectedResult = selectedcourse.SelectedCourses.Where(u => u.SNO.Replace(" ", "") == sno && u.SEMESTER.Replace(" ", "") != null).ToList(); Regex regexCharacter = new Regex("[\u4E00-\u9FA5]"); Regex regexDigit = new Regex(@"(\d{1,2})-(\d{1,2})"); foreach (var u in selectedResult) { int n = 0; MatchCollection characterRegex = regexCharacter.Matches(u.TIME); MatchCollection digitRegex = regexDigit.Matches(u.TIME); foreach (Match week in characterRegex) { int m = 0; switch (week.Value.ToString()) { case "一": number = "0"; break; case "二": number = "1"; break; case "三": number = "2"; break; case "四": number = "3"; break; case "五": number = "4"; break; } foreach (Match classTime in digitRegex) { if (m == n) { string[] firstTime = classTime.Value.ToString().Split('-'); for (int i = Convert.ToInt32(firstTime[0]) - 1; i <= Convert.ToInt32(firstTime[1]) - 1; i++) { timeTable[i, Convert.ToInt32(number)] = u.CNAME; } } m++; } n++; } } RowColKey rowColKey = null; List <RowColKey> listRowColKey = new List <RowColKey>(); for (int i = 0; i < 13; i++) { for (int j = 0; j < 5; j++) { if (timeTable[i, j] != "0") { rowColKey = new RowColKey() { Row = i, Col = j, Key = timeTable[i, j] }; listRowColKey.Add(rowColKey); } } } return(View(listRowColKey)); }