2
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文檔的代碼片段,該文檔在縱向方向模式下生成,我希望頁面處於橫向模式。所以你可以請我建議我在哪裏使用上面的代碼,你給了。在橫向模式下生成word文檔