private static void ClassToXml(string name)
    {
        if (string.IsNullOrEmpty(name))
        {
            return;
        }
        Type _type = null;

        foreach (var temp in AppDomain.CurrentDomain.GetAssemblies())
        {
            Type tempType = temp.GetType(name);
            if (tempType != null)
            {
                _type = tempType;
                break;
            }
        }

        if (_type != null)
        {
            var ints = Activator.CreateInstance(_type);
            if (ints is ConfigDataBase)
            {
                (ints as ConfigDataBase).Construct();
            }
            GameDataConvert.ClassToXml(ints);
        }
    }
    private static void ExcelToXml(string regName)
    {
        string regPath = PathConfig.OuterDataRegPath + regName;

        if (!File.Exists(regPath))
        {
            Debug.LogError("reg文件不存在" + regPath);
            return;
        }

        XmlDocument xmlDoc = new XmlDocument();
        XmlReader   reader = XmlReader.Create(regPath);

        xmlDoc.Load(reader);

        XmlNode    rootNode  = xmlDoc.SelectSingleNode("data");
        XmlElement rootEle   = (XmlElement)rootNode;
        string     className = rootEle.GetAttribute("name");
        string     excelName = rootEle.GetAttribute("from");
        string     xmlName   = rootEle.GetAttribute("to");

        Dictionary <string, SheetClass> nameSheetClassDic = new Dictionary <string, SheetClass>();

        ReadRegXmlNode(rootEle, nameSheetClassDic, 0);

        Dictionary <string, SheetData> _nameSheetDataDic = new Dictionary <string, SheetData>();
        string excelPath = PathConfig.OuterDataExcelPath + excelName;


        //读取excel的数据
        using (FileStream fs = File.Open(excelPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
            using (ExcelPackage package = new ExcelPackage(fs)) {
                ExcelWorksheets sheets = package.Workbook.Worksheets;
                for (int i = 0; i < sheets.Count; i++)
                {
                    //注意从excel读取/写入数据时,下标是从1开始的
                    ExcelWorksheet workSheet = sheets[i + 1];
                    SheetData      _shtData  = new SheetData();
                    SheetClass     _shtClass = nameSheetClassDic[workSheet.Name];
                    int            colCount  = workSheet.Dimension.End.Column;
                    int            rowCount  = workSheet.Dimension.End.Row;

                    for (int m = 0; m < _shtClass.AllVariableList.Count; m++)
                    {
                        //保存变量名和类型
                        _shtData.AllNameList.Add(_shtClass.AllVariableList[m].Name);
                        _shtData.AllTypeList.Add(_shtClass.AllVariableList[m].Type);
                    }

                    //保存每一行的数据,从第三行开始是实际的数据
                    for (int m = 3; m <= rowCount; m++)
                    {
                        RowData _rowData = new RowData();

                        int n = 1;
                        if (_shtClass.ParentVarClass != null && !string.IsNullOrEmpty(_shtClass.ParentVarClass.Foreign))
                        {
                            //如果是子表就从第二列开始读取数据
                            _shtData.IsSubSheet = true;
                            _rowData.ForeignKey = workSheet.Cells[m, 1].Value.ToString().Trim();
                            n = 2;
                        }
                        for (; n <= colCount; n++)
                        {
                            string key   = workSheet.Cells[1, n].Value.ToString().Trim();
                            string value = "";
                            if (workSheet.Cells[m, n].Value != null)
                            {
                                value = workSheet.Cells[m, n].Value.ToString().Trim();
                            }
                            _rowData.OneRowDataDic.Add(key, value);
                        }
                        _shtData.AllRowDataList.Add(_rowData);
                    }

                    _nameSheetDataDic.Add(workSheet.Name, _shtData);
                }
            }
        }

        //写入到类中
        object classObj = CreateClassObjByName(className);

        if (classObj != null)
        {
            //首先获取到外层表的表名
            List <string> outerKeyList = new List <string>();
            foreach (string str in nameSheetClassDic.Keys)
            {
                SheetClass _shtClass = nameSheetClassDic[str];
                if (_shtClass.Depth == 1)
                {
                    outerKeyList.Add(str);
                }
            }
            foreach (string str in outerKeyList)
            {
                WriteToClass(classObj, str, nameSheetClassDic, _nameSheetDataDic, "");
            }

            //xml序列化
            GameDataConvert.ClassToXml(classObj);
            AssetDatabase.Refresh();
        }
    }