using (MemoryStream generatedDocument = new MemoryStream())
{
using (WordprocessingDocument package = WordprocessingDocument.Create(generatedDocument, WordprocessingDocumentType.Document))
{
MainDocumentPart mainPart = package.MainDocumentPart;
if (mainPart == null)
{
mainPart = package.AddMainDocumentPart();
new DocumentFormat.OpenXml.Wordprocessing.Document(new DocumentFormat.OpenXml.Wordprocessing.Body()).Save(mainPart);
}
HtmlConverter converter = new HtmlConverter(mainPart);
DocumentFormat.OpenXml.Wordprocessing.Body body = mainPart.Document.Body;
var paragraphs = converter.Parse(docbody);
for (int y = 0; y < paragraphs.Count; y++)
{
body.Append(paragraphs[y]);
}
mainPart.Document.Save();
}
这在用于生成我的 word 文档的代码片段中,文档以纵向模式生成,我希望页面处于横向模式。那么您能否建议我在哪里使用您提供的上述代码。