48 lines
1.0 KiB
C#
Raw Normal View History

2025-02-27 19:15:03 +08:00
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)
{
// <20><><EFBFBD><EFBFBD>Word<72>ĵ<EFBFBD>
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());
}
// <20><EFBFBD>ı<EFBFBD>
SaveWithDialog(doc);
//Debug.Log("<22>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5>ѱ<EFBFBD><D1B1>浽: " + outputFilePath);
}
private static void SaveWithDialog(Document doc)
{
SaveFileDialog dialog = new SaveFileDialog();
dialog.Filter = "Word<72>ĵ<EFBFBD>|*.docx";
if (dialog.ShowDialog() == DialogResult.OK)
{
doc.Save(dialog.FileName);
}
}
}