From 5bbcb15dc081ede6e6d390c81e7ec64901a1988a Mon Sep 17 00:00:00 2001
From: cehua_Czg <tingame100@163.com>
Date: 星期一, 22 四月 2019 16:30:34 +0800
Subject: [PATCH] 6666 第一章NPC配置
---
Assets/Editor/Tool/ExcelReader.cs | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/Assets/Editor/Tool/ExcelReader.cs b/Assets/Editor/Tool/ExcelReader.cs
index ea7687c..36cce55 100644
--- a/Assets/Editor/Tool/ExcelReader.cs
+++ b/Assets/Editor/Tool/ExcelReader.cs
@@ -29,7 +29,7 @@
if (!txtExcelTables.ContainsKey(txtName))
{
- Debug.LogFormat("娌℃湁鎵惧埌{0}鐨凟xcel姣嶈〃.");
+ Debug.LogFormat("娌℃湁鎵惧埌{0}鐨凟xcel姣嶈〃.", 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;
--
Gitblit v1.8.0