private ISheet AddValue(ISheet sheet, ISheetDataWrapper sheetDetailDataWrapper, Type type) { IList <PropertyInfo> checkPropertyInfos = ExcelModelsPropertyManage.CreatePropertyInfos(type); Int32 cellCount = 0; foreach (var item in sheetDetailDataWrapper.Datas) { if (item == null) { StartRow++; continue; } IRow newRow = sheet.CreateRow(StartRow); buildContext.Row = newRow; foreach (PropertyInfo property in checkPropertyInfos) { Object obj = property.GetValue(item, null); Type t = property.PropertyType; ICell cell; if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IEnumerable <>)) { var ssd = ((IEnumerable)obj).Cast <IExtendedBase>(); if (ssd == null) { continue; } foreach (var v in sheetDetailDataWrapper.Titles) { IExtendedBase sv = ssd.Where(s => s.TypeId == v.TypeId).SingleOrDefault(); SetCell(newRow, cellCount++, sv.TypeValue); } continue; } SetCell(newRow, cellCount++, obj); } StartRow++; cellCount = 0; } return(sheet); }
private ISheet AddValue(ISheet sheet, ISheetDataWrapper sheetDetailDataWrapper, Type type) { IList <PropertyInfoDetail> checkPropertyInfos = ExcelModelsPropertyManage.CreatePropertyInfos(type); Int32 cellCount = 0; foreach (var item in sheetDetailDataWrapper.Datas) { if (item == null) { _startRow++; continue; } IRow newRow = sheet.CreateRow(_startRow); _buildContext.Row = newRow; foreach (PropertyInfoDetail propertyInfoDeatil in checkPropertyInfos) { Object obj = propertyInfoDeatil.PropertyInfoV.GetValue(item, null); Type t = propertyInfoDeatil.PropertyInfoV.PropertyType; if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IEnumerable <>)) { var ssd = ((IEnumerable)obj).Cast <IExtendedBase>(); if (ssd == null) { continue; } foreach (var title in sheetDetailDataWrapper.Titles) { IExtendedBase sv = ssd.SingleOrDefault(s => s.TypeId == title.TypeId); Object val = null; if (sv == null || sv.TypeValue == null) { val = ExcelModelsPropertyManage.GetExtendedDefaultValue(title.GetType()); } else { val = sv.TypeValue; } SetCell(newRow, cellCount++, val); } continue; } SetCell(newRow, cellCount++, obj == null && propertyInfoDeatil.DefaultVale != null ? propertyInfoDeatil.DefaultVale : obj); } _startRow++; cellCount = 0; } return(sheet); }