本文整理汇总了C#中WordprocessingDocument.Close方法的典型用法代码示例。如果您正苦于以下问题:C# WordprocessingDocument.Close方法的具体用法?C# WordprocessingDocument.Close怎么用?C# WordprocessingDocument.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WordprocessingDocument
的用法示例。
在下文中一共展示了WordprocessingDocument.Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: closeDocument
// Close a document
public static bool closeDocument(WordprocessingDocument doc)
{
try
{
doc.Close();
return true;
}
catch (Exception)
{
return false;
}
}
示例2: TableToWord
public void TableToWord(Wordprocessing.Table table, WordprocessingDocument document)
{
Wordprocessing.Body body = new Wordprocessing.Body();
Wordprocessing.Paragraph paragraph = new Wordprocessing.Paragraph();
body.Append(table);
body.Append(paragraph);
document.MainDocumentPart.Document.AppendChild(body);
document.MainDocumentPart.Document.Save();
document.Close();
}
示例3: WriteHtml
/// <summary>
/// Write html
/// </summary>
/// <param name="fileName"></param>
/// <param name="folderName"></param>
/// <returns></returns>
private string WriteHtml(string fileName, string folderName)
{
imageDirectory = folderName;
string htmlBody = "";
try
{
document = WordprocessingDocument.Open(fileName, false);
foreach (OpenXmlElement element in document.MainDocumentPart.Document.Body.Elements<OpenXmlElement>())
if (element is Paragraph)
htmlBody += AddParagraph((Paragraph)element);
else if (element is Table)
htmlBody += AddTable((Table)element);
document.Close();
}
catch (Exception ex)
{
throw ex;
}
return GetHtml(htmlBody);
}