public static void Export(List <string> fileList) { // 清空多语言管理器的缓存数据 LanguageMgr.Instance.ClearCacheLanguage(); // 加载多语言总表 LanguageMgr.Instance.LoadAutoGenerateLanguageToCache(); // 加载选择的Excel文件列表 for (int i = 0; i < fileList.Count; i++) { string filePath = fileList[i]; ExcelData excelFile = new ExcelData(filePath); if (excelFile.Load()) { if (excelFile.Export()) { // 导出成功后,我们解析表格的多语言数据 var data = LanguageMgr.ParseLanguage(excelFile); LanguageMgr.Instance.CacheLanguage(data); } } excelFile.Dispose(); } // 创建新的多语言总表文件 LanguageMgr.Instance.CreateAutoGenerateLanguageFile(); // 导出多语言总表文件 LanguageMgr.Instance.ExportAutoGenerateLanguageFile(); }
/// <summary> /// 导出生成按钮 /// </summary> private void createButton_Click(object sender, EventArgs e) { // 清空多语言管理器的缓存数据 LanguageMgr.Instance.ClearCacheLanguage(); // 加载多语言总表 LanguageMgr.Instance.LoadAutoGenerateLanguageToCache(); // 加载选择的Excel文件列表 for (int i = 0; i < fileListBox.Items.Count; i++) { string filePath = (string)fileListBox.Items[i]; ExcelData excelFile = new ExcelData(filePath); if (excelFile.Load()) { if (excelFile.Export()) { // 导出成功后,我们解析表格的多语言数据 var data = LanguageMgr.ParseLanguage(excelFile); LanguageMgr.Instance.CacheLanguage(data); } } excelFile.Dispose(); } // 创建新的多语言总表文件 LanguageMgr.Instance.CreateAutoGenerateLanguageFile(); // 导出多语言总表文件 LanguageMgr.Instance.ExportAutoGenerateLanguageFile(); MessageBox.Show("导表完成."); }
private void CreateButton_Click(object sender, EventArgs e) { ExcelData.CreateParams param = new ExcelData.CreateParams(); param.IsCreateTextFile = IsCreateTextFile; param.IsCreateCSFile = IsCreateCSFile; param.ClientCfgDir = ClientCfgPath; param.ClientCSDir = ClientCSPath; param.ServerCfgDir = ServerCfgPath; param.ServerCSDir = ServerCSPath; param.BattleCfgDir = BattleCfgPath; param.BattleCSDir = BattleCSPath; string[] filePaths = selectFileDialog.FileNames; for (int i = 0; i < filePaths.Length; i++) { string filePath = filePaths[i]; ExcelData data = new ExcelData(filePath); if (data.Load()) { data.Create(param); } //Dispose data.Dispose(); } //保存本地配置 SaveConfig(); }
/// <summary> /// 加载多语言总表数据到缓存 /// </summary> public void LoadAutoGenerateLanguageToCache() { string filePath = ExportConfig.Instance.LastOpenExcelPath + "//" + StrAutoGenerateLanguageExcelName + ".xlsx"; if (File.Exists(filePath)) { ExcelData excelFile = new ExcelData(filePath); if (excelFile.Load()) { for (int i = 0; i < excelFile.SheetDataList.Count; i++) { SheetData sheet = excelFile.SheetDataList[i]; var data = ParseAutoGenerateLanguageExcel(sheet); CacheLanguage(data); } } excelFile.Dispose(); } }
/// <summary> /// 多语言自动化按钮 /// 自动处理所有表格里的多语言数据 /// </summary> private void langAutoButton_Click(object sender, EventArgs e) { // 清空文件列表 fileListBox.Items.Clear(); // 获取文件 string[] files = Directory.GetFiles(ExportConfig.Instance.LastOpenExcelPath, "*.xls"); for (int i = 0; i < files.Length; i++) { string fileName = files[i]; if (fileName.Contains("$")) { continue; } fileListBox.Items.Add(fileName); } // 清空多语言管理器的缓存数据 LanguageMgr.Instance.ClearCacheLanguage(); // 加载多语言总表 LanguageMgr.Instance.LoadAutoGenerateLanguageToCache(); // 加载所有的EXCEL文件列表 for (int i = 0; i < fileListBox.Items.Count; i++) { string filePath = (string)fileListBox.Items[i]; ExcelData excelFile = new ExcelData(filePath); if (excelFile.Load()) { var data = LanguageMgr.ParseLanguage(excelFile); LanguageMgr.Instance.CacheLanguage(data); } excelFile.Dispose(); } // 创建新的多语言总表文件 LanguageMgr.Instance.CreateAutoGenerateLanguageFile(); // 导出多语言总表文件 LanguageMgr.Instance.ExportAutoGenerateLanguageFile(); MessageBox.Show($"自动化完成."); }