少年修仙传客户端基础资源
client_Wu Xijin
2019-02-14 54fad068f41ba7b0d2f16699a3f774be2a0d84e9
Assets/Editor/Tool/ExcelReader.cs
@@ -29,7 +29,7 @@
        if (!txtExcelTables.ContainsKey(txtName))
        {
            Debug.LogFormat("没有找到{0}的Excel母表.");
            Debug.LogFormat("没有找到{0}的Excel母表.", txtName);
            return string.Empty;
        }
@@ -51,18 +51,30 @@
            var extension = Path.GetExtension(path);
            if (extension.ToLower() == ".txt")
            {
                var excelPath = GetExcelPath(Path.GetFileNameWithoutExtension(path));
                var name = Path.GetFileNameWithoutExtension(path);
                var excelPath = GetExcelPath(name);
                var lines = ExcelRead(excelPath);
                File.WriteAllLines(path, lines.ToArray(), Encoding.UTF8);
                Debug.LogFormat("{0}同步完成。", name);
            }
        }
    }
    static List<string> ExcelRead(string excelPath)
    {
        var stream = File.Open(excelPath, FileMode.Open, FileAccess.Read);
        var excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
        var result = excelReader.AsDataSet();
        DataSet result = null;
        try
        {
            result = excelReader.AsDataSet(true);
        }
        catch (System.Exception ex)
        {
            Debug.LogException(ex);
        }
        int columns = result.Tables[0].Columns.Count;
        int rows = result.Tables[0].Rows.Count;