新增PC端实验报告导出功能
This commit is contained in:
parent
ad1dd6f480
commit
afc63ea87c
BIN
Assets/Plugins/Aspose.Words.dll
Normal file
BIN
Assets/Plugins/Aspose.Words.dll
Normal file
Binary file not shown.
33
Assets/Plugins/Aspose.Words.dll.meta
Normal file
33
Assets/Plugins/Aspose.Words.dll.meta
Normal file
@ -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:
|
||||
BIN
Assets/Plugins/System.Windows.Forms.dll
Normal file
BIN
Assets/Plugins/System.Windows.Forms.dll
Normal file
Binary file not shown.
33
Assets/Plugins/System.Windows.Forms.dll.meta
Normal file
33
Assets/Plugins/System.Windows.Forms.dll.meta
Normal file
@ -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:
|
||||
8
Assets/Scripts/Tools.meta
Normal file
8
Assets/Scripts/Tools.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bb2448096f447040ac74cd700f14893
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
Assets/Scripts/Tools/AsposeHelper.cs
Normal file
47
Assets/Scripts/Tools/AsposeHelper.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
11
Assets/Scripts/Tools/AsposeHelper.cs.meta
Normal file
11
Assets/Scripts/Tools/AsposeHelper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f42727d4b91acc4e938a10542fba938
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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<LocalBytesRes>().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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user