/* public void GetCollectionFromTable<T, TCollection>(TCollection collection, SpreadGetTableCollectionParams<T> param) where TCollection : ICollection<T> * { * this.GetCollectionFromTable<T, TCollection>(SpreadSheetAttributeHelper.GetTableDescription<T>(), collection, param); * } */ public void GetCollectionFromTable <T, TCollection>(TableDescription tbDesp, TCollection collection, SpreadGetTableCollectionParams <T> param) where TCollection : ICollection <T> { tbDesp.NullCheck("tbDesp"); collection.NullCheck("数据集合不能为空"); param.IintObj.NullCheck("创建空实体不能为空"); this.CheckTableExists(tbDesp.TableName); Table tb = this.Tables[tbDesp.TableName]; foreach (TableRow tr in tb.Rows) { T data = param.IintObj(); foreach (TableColumnDescription tc in tbDesp.AllColumns) { if (tb.Columns.ContainsKey(tc.ColumnName)) { CellBase cell = tr[tb.Columns[tc.ColumnName]]; if (param.SetObjProperty != null) { param.SetObjProperty(ref data, cell.Value, tc.ColumnName, tc.PropertyName); } else { SpreadSheetExcportHelper.SetPropertyValue <T>(data, tc.PropertyName, cell.Value); } } } collection.Add(data); } }
internal static void DefaultCreatingDataCellAction <T>(CellBase cell, CreatingDataCellParameters <T> result) { if (result.ColumnDescription != null) { cell.Value = result.ColumnDescription.FormatValue(result.PropertyValue); } else { cell.Value = result.PropertyValue; } }