123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using LitJson;
- using System.Collections.Generic;
- using System.IO;
- using UnityEditor;
- using UnityEngine;
- using Excel;
- using System.Data;
- public class AddItemToLocalLanguage
- {
- static string excelPath =Application.dataPath+ @"/Config/Lan/localLanguage.xlsx";
- [MenuItem("Tools/添加物品多语言表")]
- static void AddItemDesToLocalLanguage()
- {
- List<Good> goods = JsonMapper.ToObject<List<Good>>(Resources.Load<TextAsset>("goodsData").text);
- for (int i = 0; i < goods.Count; i++)
- {
- goods[i].assetsType = goods[i].dressType;
- goods[i].dressType = (goods[i].id / 10000).ToString();
- }
-
- FileInfo fileInfo = new FileInfo(excelPath);
-
-
-
-
-
-
-
-
-
-
- using (FileStream stream = File.Open(excelPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
- {
- IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
- var result = excelReader.AsDataSet();
-
- DataRow dataRow = result.Tables[0].NewRow();
- dataRow[0] = goods[0].name;
- result.Tables[0].Rows.Add(dataRow);
-
- result.AcceptChanges();
-
- AssetDatabase.SaveAssets();
- AssetDatabase.Refresh();
- }
- }
- }
|