예제 #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;
        }
    }
예제 #2
0
    /// <summary>
    /// 读取excel文件转成类的实例
    /// </summary>
    /// <param name="filePath"></param>
    /// <returns></returns>
    private object[] GetExcelDataToClassObject()
    {
        if (this.CheckAssembly() == false)
        {
            return(null);
        }
        var path  = AssetDatabase.GetAssetPath(this.SourceData);
        var excel = CaomaoEditorHelper.ReadExcel(path);

        if (excel == null)
        {
            Debug.LogError("No Excel:" + path);
            return(null);
        }
        var convert = new ExcelToClassInstanceConveter(this.assembly);

        convert.Parse(excel.Tables[0]);
        return(convert.Instances);
    }