本文整理汇总了C#中OpenXmlElement.Append方法的典型用法代码示例。如果您正苦于以下问题:C# OpenXmlElement.Append方法的具体用法?C# OpenXmlElement.Append怎么用?C# OpenXmlElement.Append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenXmlElement
的用法示例。
在下文中一共展示了OpenXmlElement.Append方法的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: AppendTo
public override void AppendTo(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
{
_mainDocumentPart = mainDocumentPart;
var imagePart = CreateImagePart();
openXmlNode.Append(CreateImageElement(mainDocumentPart.GetIdOfPart(imagePart), Path.GetFileName(_content)));
}
示例3: 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());
}
}
示例4: AppendTo
public override void AppendTo(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
{
var paragraphs = ConvertContentToParagraphs(mainDocumentPart);
foreach (var paragraph in paragraphs)
{
openXmlNode.Append(paragraph);
}
}
示例5: 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);
}
示例6: ApplyTextAlign
internal static void ApplyTextAlign(string style, OpenXmlElement styleElement)
{
JustificationValues alignment;
if (GetJustificationValue(style, out alignment))
{
styleElement.Append(new Justification() { Val = alignment });
}
}
示例7: AlignCenter
/*
internal static void AlignCenter(OpenXmlElement styleElement)
{
styleElement.Append(new Justification() { Val = JustificationValues.Center });
}
*/
internal static void ApplyVerticalTextAlign(string style, OpenXmlElement styleElement)
{
VerticalPositionValues alignment;
if (GetVerticalPositionValues(style, out alignment))
{
styleElement.Append(new VerticalTextAlignment() { Val = alignment });
}
}
示例8: AppendTo
public override void AppendTo(OpenXmlElement openXmlNode, MainDocumentPart mainDocumentPart)
{
openXmlNode.Append(GetHeaderTextElement(mainDocumentPart));
}
示例9: ApplyFont
internal static void ApplyFont(int size, bool isBold, OpenXmlElement styleElement)
{
FontSize fontSize = new FontSize() { Val = size.ToString() };
if (isBold)
{
styleElement.Append(new Bold());
}
styleElement.Append(fontSize);
}
示例10: ApplyColor
internal static void ApplyColor(string style, OpenXmlElement styleElement)
{
string hex = GetHexColor(style);
if (!string.IsNullOrEmpty(hex))
{
styleElement.Append(new Word.Color() { Val = hex });
}
}
示例11: StrParse
public static void StrParse(string str, OpenXmlElement parent)
{
if (parent == null) return;
string simpletext = "";
for (int i = 0; i < str.Length; i++)
{
switch (str[i])
{
case '\\':
var MOperator = new OXMLMathParseOperator(str, i);
//проверка на символ \\
if (MOperator.sOperator == "\\")
{
simpletext += '\\';
break;
}
//добавляем ранее пройденный текст
if (simpletext != "")
{
var rText = new OXMLMathRunWrap(simpletext);
parent.Append(rText.MainXMLElement);
simpletext = "";
}
//произошла какая либо ошибка
if (MOperator.sOperator == "") break;
//анализ операторов
if (MOperator.sOperator == @"\SUB")
{
if ((MOperator.sVar1 == "") && (MOperator.sVar2 == "")) break;
var sub = new OXMLMathSubscriptWrap();
StrParse(MOperator.sVar1, sub.XMLBase);
StrParse(MOperator.sVar2, sub.XMLSubArgument);
parent.Append(sub.MainXMLElement);
i = MOperator.iLastIndex;
}
if (MOperator.sOperator == @"\SUP")
{
if ((MOperator.sVar1 == "") && (MOperator.sVar2 == "")) break;
var sup = new OXMLMathSuperscriptWrap();
StrParse(MOperator.sVar1, sup.XMLBase);
StrParse(MOperator.sVar2, sup.XMLSuperArgument);
parent.Append(sup.MainXMLElement);
i = MOperator.iLastIndex;
}
if (MOperator.sOperator == @"\FRAC")
{
if ((MOperator.sVar1 == "") && (MOperator.sVar2 == "")) break;
var frac = new OXMLMathFractionWrap();
StrParse(MOperator.sVar1, frac.XMLNumerator);
StrParse(MOperator.sVar2, frac.XMLDenominator);
parent.Append(frac.MainXMLElement);
i = MOperator.iLastIndex;
}
break;
case '(':
int iCloseBracket = OXMLMathParseOperator.findCloseBracket(str, i);
if (iCloseBracket == -1)
{
simpletext += '(';
break;
}
string inner = str.Substring(i + 1, iCloseBracket - i - 1);
var delim = new OXMLMathDelimiterWrap();
StrParse(inner, delim.XMLBase);
parent.Append(delim.MainXMLElement);
i = iCloseBracket;
break;
default:
simpletext += str[i];
break;
}
}
//Смотрим, остался ли простой текст
if (simpletext != "")
{
var rText = new OXMLMathRunWrap(simpletext);
parent.Append(rText.MainXMLElement);
}
}
示例12: ApplyFontFamily
internal static void ApplyFontFamily(string style, OpenXmlElement styleElement)
{
styleElement.Append(new RunFonts() { Ascii = CleanFonts(style) });
}
示例13: ApplyBackGroundColor
internal static void ApplyBackGroundColor(string style, OpenXmlElement styleElement)
{
string hex = GetHexColor(style);
if (!string.IsNullOrEmpty(hex))
{
styleElement.Append(new Word.Shading()
{
Fill = hex,
Color = hex,
Val = Word.ShadingPatternValues.Clear
});
}
}
示例14: ApplyFontSize
internal static void ApplyFontSize(string style, OpenXmlElement styleElement)
{
decimal fontSize = DocxUnits.HalfPointFromStyle(style);
if (fontSize != 0)
{
fontSize = decimal.Round(fontSize);
styleElement.Append(new FontSize() { Val = fontSize.ToString("N0") });
}
}
示例15: UpdateSingleFile
private void UpdateSingleFile(OpenXmlElement root, List<OpenXmlElement> elements, List<TokensProvider> objectsWithTokens, bool removeOldOnes = true)
{
var newElements = !removeOldOnes?elements.ToList() : elements.Select(element => (OpenXmlElement) element.Clone()).ToList();
var childElements = new List<OpenXmlElement>();
var paragraphs = newElements.OfType<Paragraph>();
foreach (var paragraph in paragraphs)
childElements.AddRange(paragraph.ChildElements);
var tables = newElements.OfType<Table>();
foreach (var table in tables)
childElements.AddRange(table.ChildElements);
UpdateChildElements(childElements, objectsWithTokens);
if (removeOldOnes)
root.Append(newElements);
}