优化pc实验报告下载
This commit is contained in:
parent
3efaf5977d
commit
3bc97db54d
@ -5,14 +5,14 @@ using System.IO;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
|
||||||
public class AsposeHelper : MonoBehaviour
|
public class AsposeHelper : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public static void Writer(string json)
|
public static void Writer(string json, Action<DialogResult> callback = null)
|
||||||
{
|
{
|
||||||
Debug.LogError(File.Exists(Global.reportDemoPath));
|
|
||||||
// 加载Word文档
|
// 加载Word文档
|
||||||
Document doc = new Document(Global.reportDemoPath);
|
Document doc = new Document(Global.reportDemoPath);
|
||||||
|
|
||||||
@ -25,21 +25,23 @@ public class AsposeHelper : MonoBehaviour
|
|||||||
doc.Range.Replace($"{{{key}}}", $"{value}", new FindReplaceOptions());
|
doc.Range.Replace($"{{{key}}}", $"{value}", new FindReplaceOptions());
|
||||||
}
|
}
|
||||||
// 替换文本
|
// 替换文本
|
||||||
SaveWithDialog(doc);
|
SaveWithDialog(doc, callback);
|
||||||
//Debug.Log("文档处理完成,新文档已保存到: " + outputFilePath);
|
//Debug.Log("文档处理完成,新文档已保存到: " + outputFilePath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SaveWithDialog(Document doc)
|
private static void SaveWithDialog(Document doc, Action<DialogResult> callback)
|
||||||
{
|
{
|
||||||
SaveFileDialog dialog = new SaveFileDialog();
|
SaveFileDialog dialog = new SaveFileDialog();
|
||||||
dialog.Filter = "Word文档|*.docx";
|
dialog.Filter = "Word文档|*.docx";
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
var result = dialog.ShowDialog();
|
||||||
|
if (result == DialogResult.OK)
|
||||||
{
|
{
|
||||||
doc.Save(dialog.FileName);
|
doc.Save(dialog.FileName);
|
||||||
}
|
}
|
||||||
|
callback?.Invoke(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,12 @@ namespace QFramework.Example
|
|||||||
});
|
});
|
||||||
loader.LoadAsync();
|
loader.LoadAsync();
|
||||||
#elif UNITY_STANDALONE_WIN
|
#elif UNITY_STANDALONE_WIN
|
||||||
AsposeHelper.Writer(GetScoreDataJson());
|
DownLoad.interactable = false;
|
||||||
|
AsposeHelper.Writer(GetScoreDataJson(), result =>
|
||||||
|
{
|
||||||
|
Debug.LogError("111");
|
||||||
|
DownLoad.interactable = true;
|
||||||
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user