ExcelMediumData.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. //Excel中间数据
  5. public class ExcelMediumData
  6. {
  7. //Excel名字
  8. public string excelName;
  9. //Excel是否有效
  10. public bool isValid = false;
  11. //是否生成CSharp数据类
  12. public bool isCreateCSharp = false;
  13. //是否生成Asset创建类
  14. public bool isCreateAssignment = false;
  15. //是否生成Asset文件
  16. public bool isCreateAsset = false;
  17. //数据注释
  18. public string[] propertyNodeArray = null;
  19. //数据名称
  20. public string[] propertyNameArray = null;
  21. //数据类型
  22. public string[] propertyTypeArray = null;
  23. //List<每行数据内容>
  24. public List<string[]> allRowItemList = new List<string[]>();
  25. //注释行号
  26. public List<int> annotationRowList = new List<int>();
  27. //注释列号
  28. public List<int> annotationColList = new List<int>();
  29. //List<每行数据>,List<Dictionary<单元格字段名称, 单元格字段值>>
  30. public List<Dictionary<string,string>> GetAllRowItemDicList()
  31. {
  32. if(propertyNameArray == null || propertyNameArray.Length == 0)
  33. return null;
  34. if(allRowItemList.Count == 0)
  35. return null;
  36. List<Dictionary<string,string>> allRowItemDicList = new List<Dictionary<string,string>>(allRowItemList.Count);
  37. for(int i = 0; i < allRowItemList.Count; i++)
  38. {
  39. string[] rowArray = allRowItemList[i];
  40. //跳过空数据
  41. if(rowArray == null || rowArray.Length == 0)
  42. continue;
  43. //跳过注释数据
  44. if(annotationRowList.Contains(i))
  45. continue;
  46. //每行数据,对应字段名称和字段值
  47. Dictionary<string,string> rowDic = new Dictionary<string,string>();
  48. for(int j = 0; j < propertyNameArray.Length; j++)
  49. {
  50. //跳过注释字段
  51. if(annotationColList.Contains(j))
  52. continue;
  53. string propertyName = propertyNameArray[j];
  54. string propertyValue = j < rowArray.Length ? rowArray[j] : null;
  55. rowDic[propertyName] = propertyValue;
  56. }
  57. allRowItemDicList.Add(rowDic);
  58. }
  59. return allRowItemDicList;
  60. }
  61. }