使用xceed.words.net.docx写入docx,在VS中运行时有效,在编译exe时每页写入一行



我已经使用它一段时间了,它一直运行良好。项目在运行时写入docx日志文件。我最近修改了它写入日志的路径,供其他人使用。从那时起,当我把它作为一个内置的exe运行时,它每页写一行。但当我试图解决这个问题时,我无法在VS中重新创建它。从那时起,它就一直像以前一样工作。

有什么想法吗?有人能给我指个方向吗?

public static void WritetoLogFile(string logUpdate)
{
DateTime now            = DateTime.Now;
string logDate          = now.ToString("MM-dd");
string folderNameDate   = now.ToString("MM_dd_yyyy");
string folderName       = folderNameDate + "_Logs";
string stateFolder      = " ";
System.IO.Directory.CreateDirectory(Crawlspace.networkSharePath + "//" + folderName);
string logName = logDate + "_" + Crawlspace.browser + "_" + Crawlspace.computerName + "_" + Crawlspace.SuiteTable + ".docx";
Crawlspace.LogFileName = logName;

System.IO.Directory.CreateDirectory(Crawlspace.networkSharePath + folderName + "//" + stateFolder);
Crawlspace.LogFile = Crawlspace.networkSharePath + folderName + "//" + stateFolder + "//" + logName;
if (System.IO.File.Exists(Crawlspace.LogFile))
{
using (DocX document = DocX.Load(Crawlspace.LogFile))
{
Paragraph par1 = document.InsertParagraph();
par1.Append(logUpdate);
par1.Font("Courier New");
par1.FontSize(8);
document.Save();
}
}
else
{
using (DocX document = DocX.Create(Crawlspace.LogFile))
{
Paragraph par1 = document.InsertParagraph();
par1.Append(logUpdate);
par1.Font("Courier New");
par1.FontSize(8);
document.Save();
}
}
}

已解决:

我检查了nuget管理器中的exceed.words.net.docx dll,发现有更新。更新到最新版本,并修改了我的using语句以反映更新,现在它正在工作。。。。

using Image     = Xceed.Document.NET.Image;
using Paragraph = Xceed.Document.NET.Paragraph;
using Picture   = Xceed.Document.NET.Picture;

最新更新