/// <summary> /// 忽略名单 /// </summary> /// <param name="properties"></param> /// <returns></returns> static void IgnoreList(out List <Object> properties, bool isSim) { properties = new List <Object>(); ExcelTool excelTool = new ExcelTool(isSim); PropertyConstManager propertyConstManager = ScriptableObject.CreateInstance <PropertyConstManager>(); properties.Add(propertyConstManager); propertyConstManager.PropertyConst = excelTool.CreatePropertyConstArrayWithExcel(ExcelConfig.PropertyConst, ref propertyConstManager.Search); PropertyPropertyManager propertyPropertyManager = ScriptableObject.CreateInstance <PropertyPropertyManager>(); properties.Add(propertyPropertyManager); propertyPropertyManager.PropertyProperty = excelTool.CreatePropertyPropertyArrayWithExcel(ExcelConfig.PropertyCH2 + ExcelConfig.PropertyFight, propertyPropertyManager); }
public PropertyProperty[] CreatePropertyPropertyArrayWithExcel(string filePath, PropertyPropertyManager iProperty) { List <string> keys = new List <string>(); Dictionary <string, int> searchdic = new Dictionary <string, int>(); Dictionary <string, int> CNSearchdic = new Dictionary <string, int>(); //获得表数据 int columnNum = 0, rowNum = 0; DataRowCollection collect = ReadExcel(filePath, ref columnNum, ref rowNum, iProperty.TableName()); //根据excel的定义,第二行开始才是数据 PropertyProperty[] array = new PropertyProperty[rowNum - 2]; Dictionary <string, int> properties = new Dictionary <string, int>(); for (int i = 0; i < columnNum; i++) { if (collect[0][i].ToString() != string.Empty) { properties.Add(collect[0][i].ToString(), i); } } for (int i = 2; i < rowNum; i++) { PropertyProperty item = new PropertyProperty(); foreach (var singleProperty in properties) { PropertyInfo property = typeof(PropertyProperty).GetProperty(singleProperty.Key); if (property != null) { property.SetValue(item, DataEncryptManager.StringEncoder(TextTrans(collect[i][singleProperty.Value].ToString()))); } else { Debug.LogError(singleProperty.Key); } } //解析每列的数据 searchdic.Add(DataEncryptManager.StringEncoder(collect[i][0].ToString()), i - 2); if (!string.IsNullOrEmpty(collect[i][1].ToString())) { var str = Split(Pinyin.GetPinyin(collect[i][1].ToString())); CNSearchdic.Add(str, i - 2); keys.Add(str); } array[i - 2] = item; } iProperty.Search = JsonMapper.ToJson(searchdic); iProperty.CNSearch = JsonMapper.ToJson(CNSearchdic); CreatePropertyEnum("PropertyPropertyType", keys); return(array); }