当前位置: 首页>>代码示例>>C#>>正文


C# Body.AppendChild方法代码示例

本文整理汇总了C#中Body.AppendChild方法的典型用法代码示例。如果您正苦于以下问题:C# Body.AppendChild方法的具体用法?C# Body.AppendChild怎么用?C# Body.AppendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Body的用法示例。


在下文中一共展示了Body.AppendChild方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddParagraph

        protected void AddParagraph(Body body, JustificationValues justification, RunProperties runProperties, string text)
        {
            SetFontRunProperties(runProperties);
            var paragraph = body.AppendChild(new Paragraph()
            {
                ParagraphProperties = new ParagraphProperties()
                {
                    Justification = new Justification() { Val = justification }
                }
            });

            var run = paragraph.AppendChild(new Run() { RunProperties = runProperties });
            run.AppendChild(new Text(text));
        }
开发者ID:kateEvstratenko,项目名称:Bank,代码行数:14,代码来源:BaseDocService.cs

示例2: AddText

 private static void AddText(Body body, string text, int level)
 {
     var paragraph = body.AppendChild(new Paragraph());
     paragraph.ParagraphProperties = new ParagraphProperties()
                                         {
                                             OutlineLevel = new OutlineLevel { Val = level },
                                             ParagraphStyleId = new ParagraphStyleId() { Val = GetStyleId(level) }
                                         };
     var run = paragraph.AppendChild(new Run());
     if (level > 1)
     {
         run.AppendChild(new TabChar());
     }
     run.AppendChild(new Text(text));
 }
开发者ID:Fitzse,项目名称:FreemindToWord,代码行数:15,代码来源:Program.cs

示例3: DomReaderMiscNodeTest

        public void DomReaderMiscNodeTest()
        {
            Body body = new Body(new Paragraph(new ParagraphProperties(), new Run(new Text("test"))));
            body.PrependChild( new OpenXmlMiscNode(System.Xml.XmlNodeType.Comment, "<!-- start body -->"));

            //======== new test with a new reader ========
            OpenXmlReader reader = OpenXmlReader.Create(body, true); // read misc nodes 
            Assert.False(reader.EOF);

            bool moved = reader.Read();
            Assert.True(moved);
            Assert.False(reader.EOF);
            Assert.Equal(0, reader.Depth);
            Assert.True(reader.IsStartElement);
            Assert.False(reader.IsEndElement);
            Assert.False(reader.IsMiscNode);
            Assert.Equal("body", reader.LocalName);

            moved = reader.Read();
            Assert.True(moved);
            Assert.False(reader.EOF);
            Assert.Equal(1, reader.Depth);
            Assert.False(reader.IsStartElement);
            Assert.False(reader.IsEndElement);
            Assert.True(reader.IsMiscNode);
            Assert.Equal("#comment", reader.LocalName);

            Assert.Equal(string.Empty, reader.Prefix);
            Assert.Equal(string.Empty, reader.NamespaceUri);

            reader.Close();

            // test case: for ReadFirstChild
            reader = OpenXmlReader.Create(body, true); // read misc nodes 
            Assert.False(reader.EOF);

            moved = reader.Read();
            Assert.False(reader.EOF);

            moved = reader.ReadFirstChild();
            Assert.True(moved);
            Assert.False(reader.EOF);
            Assert.Equal(1, reader.Depth);
            Assert.False(reader.IsStartElement);
            Assert.False(reader.IsEndElement);
            Assert.True(reader.IsMiscNode);
            Assert.Equal("#comment", reader.LocalName);

            Assert.Equal(string.Empty, reader.Prefix);
            Assert.Equal(string.Empty, reader.NamespaceUri);

            reader.Close();

            OpenXmlElement miscNode = body.RemoveChild(body.FirstChild);
            body.AppendChild(miscNode);

            reader = OpenXmlReader.Create(body, true); // read misc nodes 
            Assert.False(reader.EOF);

            moved = reader.Read();
            Assert.False(reader.EOF);

            moved = reader.ReadFirstChild();
            reader.Skip();

            Assert.True(moved);
            Assert.False(reader.EOF);
            Assert.Equal(1, reader.Depth);
            Assert.False(reader.IsStartElement);
            Assert.False(reader.IsEndElement);
            Assert.True(reader.IsMiscNode);

            Assert.Equal(string.Empty, reader.Prefix);
            Assert.Equal(string.Empty, reader.NamespaceUri);

            reader.Close();

            // test case: root element is misc node
            reader = OpenXmlReader.Create(new OpenXmlMiscNode(System.Xml.XmlNodeType.ProcessingInstruction, "<?pi test?>"), true);
            moved = reader.Read();
            Assert.True(moved);
            Assert.False(reader.EOF);
            Assert.Equal(0, reader.Depth);
            Assert.False(reader.IsStartElement);
            Assert.False(reader.IsEndElement);
            Assert.True(reader.IsMiscNode);
            Assert.Equal("pi", reader.LocalName);

            Assert.Equal(string.Empty, reader.Prefix);
            Assert.Equal(string.Empty, reader.NamespaceUri);

            reader.Close();

            // case bug #253890
            body = new Body(new Paragraph(new ParagraphProperties(), new Run(new Text("test"))));
            miscNode = body.AppendChild(new OpenXmlMiscNode(System.Xml.XmlNodeType.Comment, "<!-- start body -->"));

            reader = OpenXmlReader.Create(body.FirstChild, true);
            moved = reader.Read();
            Assert.True(moved);
//.........这里部分代码省略.........
开发者ID:eriawan,项目名称:Open-XML-SDK,代码行数:101,代码来源:OpenXmlReaderTest.cs

示例4: FormatTitle

        private void FormatTitle(Body body, Module module)
        {
            var para = body.AppendChild(new Paragraph().ApplyStyle(StyleDefinitions.Heading1.Id));

            var run = para.AppendChild(new Run());

            run.AppendChild(new Text(module.Name));
        }
开发者ID:IdeaFortune,项目名称:DocumentGenerator,代码行数:8,代码来源:DocumentBuilder.cs

示例5: AddTextWithHeading

 private static void AddTextWithHeading(Body body, string heading, string text, bool indent=true)
 {
     var paragraph = body.AppendChild(new Paragraph());
     if (indent)
     {
         paragraph.ParagraphProperties = new ParagraphProperties
                                             {Indentation = new Indentation() {Start = "720"}};
     }
     var run = paragraph.AppendChild(new Run());
     run.RunProperties = new RunProperties(){Bold = new Bold()};
     run.AppendChild(new Text(heading));
     run = paragraph.AppendChild(new Run());
     run.AppendChild(new Text(": " + text));
 }
开发者ID:Fitzse,项目名称:FreemindToWord,代码行数:14,代码来源:Program.cs

示例6: ValidateBody


//.........这里部分代码省略.........
              //    <xs:element name="proofErr" minOccurs="0" type="CT_ProofErr"></xs:element>
              //    <xs:element name="permStart" minOccurs="0" type="CT_PermStart"></xs:element>
              //    <xs:element name="permEnd" minOccurs="0" type="CT_Perm"></xs:element>
              //  </xs:choice>
              //</xs:group>

              //<xs:group name="EG_RangeMarkupElements">
              //  <xs:choice>
              //    <xs:group ref="EG_RangeMarkupElementsNoRev" minOccurs="0" maxOccurs="unbounded" />
              //    <xs:group ref="EG_RangeMarkupElementsRev" minOccurs="0" maxOccurs="unbounded" />
              //    <xs:element ref="w14:customXmlConflictInsRangeStart" minOccurs="0" />
              //    <xs:element ref="w14:customXmlConflictInsRangeEnd" minOccurs="0" />
              //    <xs:element ref="w14:customXmlConflictDelRangeStart" minOccurs="0" />
              //    <xs:element ref="w14:customXmlConflictDelRangeEnd" minOccurs="0" />
              //  </xs:choice>
              //</xs:group>

              //<xsd:group name="EG_MathContent">
              //  <xsd:choice>
              //    <xsd:element ref="m:oMathPara"></xsd:element>
              //    <xsd:element ref="m:oMath"></xsd:element>
              //  </xsd:choice>
              //</xsd:group>

            // ################ the above schema has been changed by EcmaD ##############

            // ***** good case ******

            // empty is ok
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            // 
            body.AppendChild(new SectionProperties());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            body.PrependChild(new AltChunk());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            // multiple AltChunk is ok
            body.PrependChild(new AltChunk());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            body.InsertAfter(new Paragraph(), body.FirstChild);
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            body.PrependChild(new MoveFromRangeStart());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            body.PrependChild(new MoveFromRun());
            target.Validate(validationContext);
            Assert.True(actual.Valid);

            //body.PrependChild(new DocumentFormat.OpenXml.Math.OfficeMath());
            //target.Validate(validationContext);
            //Assert.True(actual.Valid);

            //body.PrependChild(new DocumentFormat.OpenXml.Math.OfficeMath());
            //target.Validate(validationContext);
            //Assert.True(actual.Valid);
开发者ID:eriawan,项目名称:Open-XML-SDK,代码行数:66,代码来源:CompositeParticleValidatorTest.cs

示例7: CreateFromScratch

        public void CreateFromScratch()
        {
            //ExStart
            //ExFor:Node.GetText
            //ExFor:CompositeNode.RemoveAllChildren
            //ExFor:CompositeNode.AppendChild
            //ExFor:Section
            //ExFor:Section.#ctor
            //ExFor:Section.PageSetup
            //ExFor:PageSetup.SectionStart
            //ExFor:PageSetup.PaperSize
            //ExFor:SectionStart
            //ExFor:PaperSize
            //ExFor:Body
            //ExFor:Body.#ctor
            //ExFor:Paragraph
            //ExFor:Paragraph.#ctor
            //ExFor:Paragraph.ParagraphFormat
            //ExFor:ParagraphFormat
            //ExFor:ParagraphFormat.StyleName
            //ExFor:ParagraphFormat.Alignment
            //ExFor:ParagraphAlignment
            //ExFor:Run
            //ExFor:Run.#ctor(DocumentBase)
            //ExFor:Run.Text
            //ExFor:Inline.Font
            //ExSummary:Creates a simple document from scratch using the Aspose.Words object model.

            // Create an "empty" document. Note that like in Microsoft Word,
            // the empty document has one section, body and one paragraph in it.
            Aspose.Words.Document doc = new Aspose.Words.Document();

            // This truly makes the document empty. No sections (not possible in Microsoft Word).
            doc.RemoveAllChildren();

            // Create a new section node.
            // Note that the section has not yet been added to the document,
            // but we have to specify the parent document.
            Aspose.Words.Section section = new Aspose.Words.Section(doc);

            // Append the section to the document.
            doc.AppendChild(section);

            // Lets set some properties for the section.
            section.PageSetup.SectionStart = SectionStart.NewPage;
            section.PageSetup.PaperSize = PaperSize.Letter;

            // The section that we created is empty, lets populate it. The section needs at least the Body node.
            Body body = new Body(doc);
            section.AppendChild(body);

            // The body needs to have at least one paragraph.
            // Note that the paragraph has not yet been added to the document,
            // but we have to specify the parent document.
            // The parent document is needed so the paragraph can correctly work
            // with styles and other document-wide information.
            Paragraph para = new Paragraph(doc);
            body.AppendChild(para);

            // We can set some formatting for the paragraph
            para.ParagraphFormat.StyleName = "Heading 1";
            para.ParagraphFormat.Alignment = ParagraphAlignment.Center;

            // So far we have one empty paragraph in the document.
            // The document is valid and can be saved, but lets add some text before saving.
            // Create a new run of text and add it to our paragraph.
            Run run = new Run(doc);
            run.Text = "Hello World!";
            run.Font.Color = System.Drawing.Color.Red;
            para.AppendChild(run);

            // As a matter of interest, you can retrieve text of the whole document and
            // see that \x000c is automatically appended. \x000c is the end of section character.
            Console.WriteLine("Hello World!\x000c", doc.GetText());

            // Save the document.
            doc.Save(ExDir + "Section.CreateFromScratch Out.doc");
            //ExEnd

            Assert.AreEqual("Hello World!\x000c", doc.GetText());
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:81,代码来源:ExSection.cs


注:本文中的Body.AppendChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。