diff --git a/Assets/Plugins/Aspose.Words.dll b/Assets/Plugins/Aspose.Words.dll new file mode 100644 index 00000000..8e03f7ee Binary files /dev/null and b/Assets/Plugins/Aspose.Words.dll differ diff --git a/Assets/Plugins/Aspose.Words.dll.meta b/Assets/Plugins/Aspose.Words.dll.meta new file mode 100644 index 00000000..5b1a657c --- /dev/null +++ b/Assets/Plugins/Aspose.Words.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: ba16243601d48674bbd94478034635d0 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/System.Windows.Forms.dll b/Assets/Plugins/System.Windows.Forms.dll new file mode 100644 index 00000000..3a6eff82 Binary files /dev/null and b/Assets/Plugins/System.Windows.Forms.dll differ diff --git a/Assets/Plugins/System.Windows.Forms.dll.meta b/Assets/Plugins/System.Windows.Forms.dll.meta new file mode 100644 index 00000000..278d5520 --- /dev/null +++ b/Assets/Plugins/System.Windows.Forms.dll.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 82549cd4bc10d654d876aaf0f7f4b64d +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Tools.meta b/Assets/Scripts/Tools.meta new file mode 100644 index 00000000..65dc2ed5 --- /dev/null +++ b/Assets/Scripts/Tools.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6bb2448096f447040ac74cd700f14893 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Tools/AsposeHelper.cs b/Assets/Scripts/Tools/AsposeHelper.cs new file mode 100644 index 00000000..3d70891c --- /dev/null +++ b/Assets/Scripts/Tools/AsposeHelper.cs @@ -0,0 +1,47 @@ +using Aspose.Words; +using Aspose.Words.Replacing; +using QFramework; +using System.IO; +using UnityEngine; +using System.Windows.Forms; +using Newtonsoft.Json.Linq; + +public class AsposeHelper : MonoBehaviour +{ + + + public static void Writer(string json) + { + + // 加载Word文档 + Document doc = new Document(Global.reportDemoPath); + + JObject jObject = JObject.Parse(json); + + foreach (JProperty property in jObject.Properties()) + { + string key = property.Name; + string value = property.Value.ToString(); + doc.Range.Replace($"{{{key}}}", $"{value}", new FindReplaceOptions()); + } + // 替换文本 + SaveWithDialog(doc); + //Debug.Log("文档处理完成,新文档已保存到: " + outputFilePath); + + + + + } + + private static void SaveWithDialog(Document doc) + { + SaveFileDialog dialog = new SaveFileDialog(); + dialog.Filter = "Word文档|*.docx"; + if (dialog.ShowDialog() == DialogResult.OK) + { + doc.Save(dialog.FileName); + } + } +} + + diff --git a/Assets/Scripts/Tools/AsposeHelper.cs.meta b/Assets/Scripts/Tools/AsposeHelper.cs.meta new file mode 100644 index 00000000..03199d2b --- /dev/null +++ b/Assets/Scripts/Tools/AsposeHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7f42727d4b91acc4e938a10542fba938 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/UIScore.cs b/Assets/Scripts/UI/UIScore.cs index 0805b625..68ff27c3 100644 --- a/Assets/Scripts/UI/UIScore.cs +++ b/Assets/Scripts/UI/UIScore.cs @@ -22,27 +22,36 @@ namespace QFramework.Example } + +#if UNITY_WEBGL ResLoader loader = ResLoader.Allocate(); loader.Add2Load(Global.reportDemoPath.ToLocalBytesResName(), (success, res) => { if (success) { byte[] bytes = res.As().bytes; - var data = new LabReprotData(); - data.realname = InputName.text; - data.biaobencaiji_1_buzhou_1 = "[1111]"; - string json = JsonConvert.SerializeObject(data); -#if UNITY_WEBGL - WebGLDownLoadFile.Instance.DownloadDocx(bytes, json); -#endif + WebGLDownLoadFile.Instance.DownloadDocx(bytes, GetScoreDataJson()); + } }); loader.LoadAsync(); +#elif UNITY_STANDALONE_WIN + AsposeHelper.Writer(GetScoreDataJson()); +#endif + }); Confirm.onClick.AddListener(Hide); } + public string GetScoreDataJson() + { + var data = new LabReprotData(); + data.realname = InputName.text; + data.biaobencaiji_1_buzhou_1 = "[1111]"; + string json = JsonConvert.SerializeObject(data); + return json; + } protected override void OnOpen(IUIData uiData = null)