| | |
| | | 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; |