本文整理汇总了C#中OpenXmlElement类的典型用法代码示例。如果您正苦于以下问题:C# OpenXmlElement类的具体用法?C# OpenXmlElement怎么用?C# OpenXmlElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpenXmlElement类属于命名空间,在下文中一共展示了OpenXmlElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyFontStyle
internal static void ApplyFontStyle(string style, OpenXmlElement styleElement)
{
if (string.Compare(italic, style, StringComparison.InvariantCultureIgnoreCase) == 0)
{
styleElement.Append(new Italic());
}
}
示例2: SetMarginBottom
private void SetMarginBottom(OpenXmlElement parent)
{
Paragraph para = parent.AppendChild(new Paragraph());
para.ParagraphProperties = new ParagraphProperties();
DocxMargin.SetBottomMargin(defaultDLMargin, para.ParagraphProperties);
}
示例3: InsertAfter
public override void InsertAfter(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
{
_mainDocumentPart = mainDocumentPart;
var imagePart = CreateImagePart();
openXmlNode.InsertAfterSelf(CreateImageElement(mainDocumentPart.GetIdOfPart(imagePart), Path.GetFileName(_content)));
}
示例4: AppendTo
public override void AppendTo(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
{
_mainDocumentPart = mainDocumentPart;
var imagePart = CreateImagePart();
openXmlNode.Append(CreateImageElement(mainDocumentPart.GetIdOfPart(imagePart), Path.GetFileName(_content)));
}
示例5: CreateParagraph
private Paragraph CreateParagraph(DocxNode node, OpenXmlElement parent)
{
Paragraph para = parent.AppendChild(new Paragraph());
OnParagraphCreated(node, para);
OnOLParagraphCreated(this, new ParagraphEventArgs(para));
return para;
}
示例6: GetXPath
/// <summary>
/// Gets XmlPath information of the specified OpenXmlElement.
/// </summary>
/// <param name="element">The OpenXmlElement.</param>
/// <returns>XmlPath to this element from root element.</returns>
internal static XmlPath GetXPath(OpenXmlElement element)
{
if (element == null)
{
return null;
// throw new ArgumentNullException("element");
}
XmlPath xmlPath = new XmlPath();
xmlPath.PartUri = element.GetPartUri();
Dictionary<string, string> namespaces = new Dictionary<string, string>();
StringBuilder xpath = new StringBuilder("");
BuildXPath(element, xpath, namespaces);
xmlPath.XPath = xpath.ToString();
StringBuilder nsString;
foreach (var ns in namespaces)
{
nsString = new StringBuilder("");
nsString.Append("xmlns:");
nsString.Append(ns.Key);
nsString.Append("=\"");
nsString.Append(ns.Value);
nsString.Append("\"");
xmlPath.NamespacesDefinitions.Add(nsString.ToString());
}
return xmlPath;
}
示例7: ApplyFontWeight
internal static void ApplyFontWeight(string style, OpenXmlElement styleElement)
{
if (string.Compare(bold, style, StringComparison.InvariantCultureIgnoreCase) == 0 ||
string.Compare(bolder, style, StringComparison.InvariantCultureIgnoreCase) == 0)
{
styleElement.Append(new Bold());
}
}
示例8: AppendTo
public override void AppendTo(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
{
var paragraphs = ConvertContentToParagraphs(mainDocumentPart);
foreach (var paragraph in paragraphs)
{
openXmlNode.Append(paragraph);
}
}
示例9: AppendTo
public override void AppendTo(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
{
var text = _newParagraph
? (OpenXmlElement)new Paragraph(new Run(new Text(_content)))
: (OpenXmlElement)new Run(new Text(_content));
openXmlNode.Append(text);
}
示例10: ApplyTextAlign
internal static void ApplyTextAlign(string style, OpenXmlElement styleElement)
{
JustificationValues alignment;
if (GetJustificationValue(style, out alignment))
{
styleElement.Append(new Justification() { Val = alignment });
}
}
示例11: InsertAfter
public override void InsertAfter(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
{
var paragraphs = ConvertContentToParagraphs(mainDocumentPart);
var insertPoint = openXmlNode;
foreach (var paragraph in paragraphs)
{
insertPoint.InsertAfterSelf(paragraph);
insertPoint = paragraph;
}
}
示例12: OpenXmlDomReader
/// <summary>
/// Initializes a new instance of the OpenXmlDomReader class using the supplied OpenXmlElement and Boolean values.
/// </summary>
/// <param name="openXmlElement">The OpenXmlElement to read.</param>
/// <param name="readMiscNodes">Specify false to indicate to the reader to skip all miscellaneous nodes. The default value is false.</param>
public OpenXmlDomReader(OpenXmlElement openXmlElement, bool readMiscNodes)
: this(readMiscNodes)
{
if (openXmlElement == null)
{
throw new ArgumentNullException("openXmlElement");
}
this.Init(openXmlElement);
}
示例13: ApplyTextDecoration
internal static void ApplyTextDecoration(string style, OpenXmlElement styleElement)
{
if (string.Compare(style, underLine, StringComparison.InvariantCultureIgnoreCase) == 0)
{
styleElement.Append(new Underline() { Val = UnderlineValues.Single });
}
else if (string.Compare(style, lineThrough, StringComparison.InvariantCultureIgnoreCase) == 0)
{
styleElement.Append(new Strike());
}
}
示例14: GetMergeRuns
public static IEnumerable<MergeField> GetMergeRuns(OpenXmlElement element)
{
// Gets each element under the element with text representing a merge field.
foreach (var run in element.Descendants<Run>())
{
if (run.InnerText.StartsWith(MergeField.StartMergeField.ToString())
&& run.InnerText.EndsWith(MergeField.EndMergeField.ToString()))
{
yield return ConvertRunToMergeField(run);
}
}
}
示例15: AddCallBackMethod
public void AddCallBackMethod(OpenXmlElement element, CallBackMethod method)
{
if (!_callBackMethods.Keys.Contains(element.ElementTypeId))
{
_callBackMethods.Add(element.ElementTypeId, new List<CallBackMethod>());
}
// _callBackMethods[element.ElementTypeId] is a List. Let's check if the method obj is already added to the list.
if (!_callBackMethods[element.ElementTypeId].Contains(method))
{
_callBackMethods[element.ElementTypeId].Add(method);
}
}