using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Reflection; using System.Text; namespace XYY.Core.Standard.ExcelHelper.MSExcelHelper { public class MSExcelTableMapping : MSExcelClassMapping { } public class MSExcelDefaultMapping : MSExcelClassMapping { } public abstract class MSExcelClassMapping { public virtual int[] SheetIndexs(List sheetNames) { return new int[] { 1 }; } public virtual int RemarkIndex() { return 0; } public List Items { get; set; } = new List(); public List Attrs { get; set; } = new List(); //public List items => new List(); public ExcelMappingItem Map(Expression> expression) { var MappingItem = new ExcelMappingItem(); if (expression.Body.NodeType == ExpressionType.MemberAccess) { MemberExpression memberExpression = expression.Body as MemberExpression; MappingItem = Map(memberExpression.Member); MappingItem.LambdaExpression = expression; } return MappingItem; } public ExcelMappingItem Map(MemberInfo memberInfo) { var MappingItem = new ExcelMappingItem(); if (memberInfo.MemberType == MemberTypes.Property) { PropertyInfo propertyInfo = memberInfo as PropertyInfo; MappingItem.PropertyInfo = propertyInfo; var pt = MappingItem.PropertyInfo.PropertyType; MappingItem.ColumnFormattext = ExcelFormattextHelper.GetColumnFormattext(pt); Items.Add(MappingItem); return MappingItem; } else { return MappingItem; } } } }