本文整理汇总了C#中Run.Elements方法的典型用法代码示例。如果您正苦于以下问题:C# Run.Elements方法的具体用法?C# Run.Elements怎么用?C# Run.Elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Run
的用法示例。
在下文中一共展示了Run.Elements方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRun
/// <summary>
/// Add run
/// </summary>
/// <param name="run"></param>
/// <returns></returns>
private string AddRun(Run run)
{
string runText = "";
foreach (OpenXmlElement element in run.Elements())
{
if (element is TabChar)
{
runText += "  ";
}
else if (element is Text)
{
string textEncode = HttpUtility.HtmlEncode(element.InnerText);
if (textEncode.TakeWhile(x => x == ' ').Count() >= textEncode.Length / 2)
{
if (element.HasAttributes)
{
if (element.GetAttributes().Where(x => x.LocalName == "space" && x.Value == "preserve").FirstOrDefault() != null)
textEncode = textEncode.Replace(" ", " ");
}
}
runText += textEncode;
}
else if (element is Break)
{
runText += "<br/>";
}
else if (element is SymbolChar)
{
runText += AddSymbolChar((SymbolChar)element);
}
else if (element is Picture)
{
runText += AddPicture((Picture)element);
}
else if (element is Drawing)
{
runText += AddDrawing((Drawing)element);
}
else if (element is AlternateContent)
{
runText += AddAlternateContent((AlternateContent)element);
}
else if (element is RunProperties)
{
}
else if (element is EmbeddedObject)
{
runText += AddEmbeddedObject((EmbeddedObject)element);
}
}
if (run.RunProperties != null)
runText = AddFormat(runText, run.RunProperties);
return runText;
}