我正在使用OpenXML创建一个非常简单的WordprocessingDocument
,如下所示:
public byte[] SaveCoveringLetter(string path, string coveringLetter)
{
byte[] result;
using (WordprocessingDocument document = WordprocessingDocument.Create(path, WordprocessingDocumentType.Document))
{
document.AddMainDocumentPart();
document.MainDocumentPart.Document = new DocumentFormat.OpenXml.Wordprocessing.Document(new Body(new Paragraph(new Run(new DocumentFormat.OpenXml.Wordprocessing.Text(coveringLetter)))));
document.MainDocumentPart.Document.Save();
document.Close();
result = System.IO.File.ReadAllBytes(path);
}
System.IO.File.Delete(path);
return result;
}
然后我使用这个字节数组在一个数据包中发送,但是当它到达另一侧时,它是以doc的格式但是换行符丢失了?如何保留换行符?