word模板替换2

using System;
using System.IO;

namespace WordExportDemo
{
internal class Program
{
private static void Main(string[] args)
{
//Tests.FormTableTest.Test();
//Tests.FormTest.Test();
//Tests.TableListTest.Test();
//Tests.WtTest.Test();
//Tests.CourtRecord.Create();
// Tests.CourtRecord.Create();
string root = System.AppDomain.CurrentDomain.BaseDirectory;
string tempPath = root + Path.Combine("TempleCourt", "调解笔录2.docx");
CourtRecord model = new CourtRecord();
model.title = "福州市仲裁院";
model.time = "2021年9月17号20点55分";
model.address = "福州市鼓楼区";
model.caseNo = "福仲案001号";
MemoryStream ms = DocHelper.ExportDoc<CourtRecord>(model, tempPath);
byte [] dataByte= ms.ToArray();
string docPath = root + Path.Combine("TempleCourt",DateTime.Now.ToString("yyyyMMddhh")+"调解笔录.docx");
if (File.Exists(docPath) == false)
{
File.Create(docPath);

}

using (FileStream fs = new FileStream(docPath, FileMode.Create))
{
fs.Write(dataByte, 0, dataByte.Length);
}

 

Console.WriteLine("导出完成,"+ docPath);
Console.ReadKey();
}
}
}

上一篇:python – Pyside安装“无法在您的系统上找到MSVC编译器版本10.0”


下一篇:java中的*/开源屏幕捕获库