private static void TestXlsx() { string filePath = "test.xlsx"; Xlsx xlsx = Xlsx.Create(filePath); StringBuilder sb = new StringBuilder(); xlsx.ExportCSharp(sb); File.WriteAllText(string.Format("GameData/{0}.cs", xlsx.FileName), sb.ToString()); Properties prop = Properties.CreateFromXlsx(xlsx); SecurityElement root = Properties.ConvertPropertiesToXML(prop); // 格式化 XElement element = XElement.Parse(root.ToString()); File.WriteAllText("xlsx_2_properties_2_xml.xml", element.ToString()); }
private static bool ExportCS(Xlsx xlsx) { Properties historyProp = MainEntry.XlsxHistory.GetNamespace(xlsx.FileName, false, false); if (historyProp == null) { historyProp = MainEntry.XlsxHistory.Append(xlsx.FileName, xlsx.FileName); historyProp.SetString("FilePath", xlsx.RecordInfo.FilePath); } string sheetHash = historyProp.GetString("SheetHash", null); if (sheetHash != xlsx.RecordInfo.SheetHash) { historyProp.SetString("SheetHash", xlsx.RecordInfo.SheetHash); MainEntry.Config.SetString("export_cs", "true"); StringBuilder builder = new StringBuilder(); xlsx.ExportCSharp(builder); File.WriteAllText(string.Format("{0}/{1}.cs", MakeDir(MainEntry.Config.GetString("cs_dir", null)), xlsx.FileName), builder.ToString()); } return(true); }