少年修仙传客户端基础资源
client_Wu Xijin
2018-10-11 217ecd1f25247024faa3aed8ae0174c1764162d2
3335 添加一套在unity中点击配置文件用excel打开查看的功能.
1个文件已修改
16 ■■■■ 已修改文件
Assets/Editor/Tool/ExcelReader.cs 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Assets/Editor/Tool/ExcelReader.cs
@@ -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;