Esempio n. 1
0
    public void ExportData()
    {
        if (string.IsNullOrEmpty(this.ExportFolderPath))
        {
            EditorUtility.DisplayDialog("导出出错", "请选择导出文件目录", "确定");
            return;
        }
        var path = AssetDatabase.GetAssetPath(this.SourceData);

        if (path.EndsWith(DataToDataOperator.ExcelExtension1) ||
            path.EndsWith(DataToDataOperator.ExcelExtension2))
        {
            //说明是excel文件
            var excel = CaomaoEditorHelper.ReadExcel(path);
            if (excel == null)
            {
                Debug.LogError("No Excel:" + path);
                return;
            }
            var conveter = new ExcelToClassTypeConveter(excel.Tables[0], this.LoadTemplate(), this.nameSpace, this.ExportFolderPath);
            conveter.Parse();
            AssetDatabase.Refresh();
        }
        else
        {
            EditorUtility.DisplayDialog("文件格式不支持", "请选择Excel文件作为配置文件", "确定");
            return;
        }
    }
Esempio n. 2
0
 public CaomaoExcelFieldSimpleData(string fn, string ft, string fv, DataSet excel, ExcelToClassTypeConveter con)
 {
     this.fieldName  = fn;
     this.fieldType  = ft;
     this.fieldValue = fv;
     this.excel      = excel;
     this.conveter   = con;
 }
Esempio n. 3
0
 public void Parse()
 {
     this.realFieldType = this.GetTypeFromString(this.fieldType);
     if (this.fieldType.StartsWith("list"))
     {
         this.BList = true;
         //需要转化fieldType
         if (this.fieldType == "list<T>")
         {
             //特殊化需要再次生成一个类
             if (this.excel.HasTable(this.fieldValue, out var table))
             {
                 var className = table.Rows[0][0].ToString();
                 this.realFieldType = $"List<{className}>";
                 var temp = new ExcelToClassTypeConveter(table, conveter.template, conveter.nameSpace, conveter.exprotPath);
                 temp.Parse();
             }
         }
     }
 }