public static void ExportData(string exportPath, string savaPath) { //-- Load Excel ExcelLoader excel = new ExcelLoader(exportPath, 3, exportPath.GetFileNameWithoutExtend()); //-- export JsonExporter exporter = new JsonExporter(excel); exporter.SaveToFile(savaPath + "/" + exportPath.GetFileNameWithoutExtend() + ".json", Encoding.UTF8); CSharpExporter csharp = new CSharpExporter(excel.Sheets[0], exportPath.GetFileNameWithoutExtend()); csharp.CreatCSharpScript(); #if UNITY_EDITOR AssetDatabase.Refresh(); #endif }
/// <summary> /// 加载Excel文件 /// </summary> /// <param name="options">导入设置</param> public void loadExcel(Program.Options options) { _options = options; //-- Excel File string excelPath = options.excelPath; string excelName = Path.GetFileNameWithoutExtension(excelPath); HashSet <string> exportTags = new HashSet <string>(); exportTags.Add(""); if (options.exportTags != null) { var tags = options.exportTags.Split(','); foreach (var tag in tags) { exportTags.Add(tag); } } //-- Encoding _encoding = new UTF8Encoding(false); //-- Load Excel ExcelLoader excel = new ExcelLoader(excelPath); //-- Parse Excel List <ExcelParser.TableInfo> tableInfos = ExcelParser.ReadSheetData(excel.Sheets[0]); //-- 导出 json _json = new JsonExporter(tableInfos, excelName, exportTags); //-- 导出 xml _xml = new XmlExporter(tableInfos, excelName, exportTags); //-- C# 结构体定义 _csharp = new CSharpExporter(tableInfos, excelName, exportTags); }