private void SetStatisticsTable() { var map = ""; var columns = new List <StatisticsSetting>(); var settings = new List <StatisticsModuleSetting>(); if (CurrentStatistics != null) { try { columns = JsonConvert.DeserializeObject <List <StatisticsSetting> >(CurrentStatistics.Columns); } catch (Exception e) { var m = JsonConvert.DeserializeObject <Dictionary <string, string> >(CurrentStatistics.Columns); columns = new List <StatisticsSetting>(); foreach (var key in m.Keys) { columns.Add(new StatisticsSetting() { ItemName = key, BindField = m[key], }); } } } if (columns == null) { columns = new List <StatisticsSetting>(); } if (SelectionModule != null) { map = Convert.ToString(SelectionModule["StatisticsMap"]); settings = JsonConvert.DeserializeObject <List <StatisticsModuleSetting> >(map); } if (settings == null) { settings = new List <StatisticsModuleSetting>(); } var fixIndex = 0; foreach (var column in columns) { var setting = settings.Find(m => m.StatisticsItemName == column.ItemName); if (setting == null) { settings.Insert(0, new StatisticsModuleSetting() { StatisticsItemName = column.ItemName, BindField = column.BindField }); fixIndex++; } } var sheet = CloneSheet(TableStatistics.ActiveSheet, settings.Count); var index = 0; foreach (var set in settings) { if (index < fixIndex) { FarPointExtensions.LockCell(sheet.Cells[index, 6], "#"); FarPointExtensions.LockCell(sheet.Cells[index, 1], "#"); FarPointExtensions.LockCell(sheet.Cells[index, 0], "#"); } sheet.Cells[index, 0].Value = set.StatisticsItemName; sheet.Cells[index, 1].Value = GetKey(set.BindField); sheet.Cells[index, 2].Value = set.SheetName; sheet.Cells[index, 2].Tag = set.SheetID; sheet.Cells[index, 3].Value = set.CellName; sheet.Cells[index, 3].Tag = set.CellName; index += 1; } TableStatistics.Sheets.Clear(); TableStatistics.Sheets.Add(sheet); sheet.CellChanged += new SheetViewEventHandler(TableStatistics_Sheet1_CellChanged); }