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


C# Body.Append方法代码示例

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


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

示例1: GenerateDocument

        public static Document GenerateDocument()
        {
            Document document1 = new Document() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 wp14" } };
            document1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            document1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            document1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            document1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            document1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            document1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            document1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            DocumentBackground documentBackground1 = new DocumentBackground() { Color = "FF0000" };

            V.Background background1 = new V.Background() { Id = "_x0000_s1025", BlackWhiteMode = Ovml.BlackAndWhiteModeValues.GrayScale, TargetScreenSize = Ovml.ScreenSizeValues.Sz1024x768 };
            V.Fill fill1 = new V.Fill() { Type = V.FillTypeValues.Frame, Title = "Wedding_EnclosureCards", Recolor = true, Color = "FF0000" };

            background1.Append(fill1);

            documentBackground1.Append(background1);

            Body body1 = new Body();

            Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "005F6C39", RsidRunAdditionDefault = "005F6C39" };
            BookmarkStart bookmarkStart1 = new BookmarkStart() { Name = "_GoBack", Id = "0" };
            BookmarkEnd bookmarkEnd1 = new BookmarkEnd() { Id = "0" };

            paragraph1.Append(bookmarkStart1);
            paragraph1.Append(bookmarkEnd1);

            SectionProperties sectionProperties1 = new SectionProperties() { RsidR = "005F6C39" };
            PageSize pageSize1 = new PageSize() { Width = (UInt32Value)12240U, Height = (UInt32Value)15840U };
            PageMargin pageMargin1 = new PageMargin() { Top = 1440, Right = (UInt32Value)1440U, Bottom = 1440, Left = (UInt32Value)1440U, Header = (UInt32Value)720U, Footer = (UInt32Value)720U, Gutter = (UInt32Value)0U };
            Columns columns1 = new Columns() { Space = "720" };
            DocGrid docGrid1 = new DocGrid() { LinePitch = 360 };

            sectionProperties1.Append(pageSize1);
            sectionProperties1.Append(pageMargin1);
            sectionProperties1.Append(columns1);
            sectionProperties1.Append(docGrid1);

            body1.Append(paragraph1);
            body1.Append(sectionProperties1);

            document1.Append(documentBackground1);
            document1.Append(body1);
            return document1;
        }
开发者ID:haizhixing126,项目名称:PYSConsole,代码行数:55,代码来源:WordGenerator.cs

示例2: WriteDocx

        public void WriteDocx(Body body, Func<string, string, bool> majorCave)
        {
            List<Cave> majorCaves = new List<Cave>();
              List<Cave> minorCaves = new List<Cave>();
              body.Append(Docx.SimpleParagraph(Name, StyleNames.AreaHeader));

              foreach (Cave cave in Caves)
              {
            cave.IsMajorCave = majorCave(Name, cave.Name);
            if (cave.IsMajorCave)
              majorCaves.Add(cave);
            else
              minorCaves.Add(cave);
              }

              majorCaves.Sort(new CaveSortComparer());
              minorCaves.Sort(new CaveSortComparer());
              foreach (Cave cave in majorCaves)
            cave.WriteDocx(body);
              if (minorCaves.Count > 0)
              {
            body.Append(Docx.SimpleParagraph("Minor Caves", StyleNames.MinorCavesHeader));
            foreach (Cave cave in minorCaves)
              cave.WriteDocx(body);
              }
        }
开发者ID:samgoat,项目名称:NC,代码行数:26,代码来源:Area.cs

示例3: Format

        public void Format(Body body, Step step)
        {
            // HACK - We need to generate a custom paragraph here because 2 Run objects are needed to allow for the bolded keyword
            var paragraph = new Paragraph(new ParagraphProperties(new ParagraphStyleId {Val = "Normal"}));
            paragraph.Append(new Run(new RunProperties(new Bold()), new Text(step.NativeKeyword)));
            var nameText = new Text {Space = SpaceProcessingModeValues.Preserve};
            nameText.Text = " " + step.Name;
            paragraph.Append(new Run(nameText));
            body.Append(paragraph);

            if (!string.IsNullOrEmpty(step.DocStringArgument))
            {
                string[] lines = step.DocStringArgument.Split(new[] {Environment.NewLine},
                                                              StringSplitOptions.RemoveEmptyEntries);
                foreach (string line in lines)
                {
                    body.GenerateParagraph(line, "Quote");
                }
            }

            if (step.TableArgument != null)
            {
                this.wordTableFormatter.Format(body, step.TableArgument);
            }
        }
开发者ID:eduaquiles,项目名称:pickles,代码行数:25,代码来源:WordStepFormatter.cs

示例4: Format

	    public void Format(Body body, Scenario background)
		{
			var headerParagraph   = new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Heading2" }));
		    var backgroundKeyword = GetLocalizedBackgroundKeyword();
			headerParagraph.Append(new Run(new RunProperties(new Bold()), new Text(backgroundKeyword)));

			var table = new Table();
			table.Append(GenerateTableProperties());
			var row = new TableRow();
			var cell = new TableCell();
			cell.Append(headerParagraph);

		    foreach (var descriptionSentence in WordDescriptionFormatter.SplitDescription(background.Description))
		    {
		        cell.Append(CreateNormalParagraph(descriptionSentence));
		    }

			foreach (var step in background.Steps)
			{
                cell.Append(WordStepFormatter.GenerateStepParagraph(step));

                if (step.TableArgument != null)
                {
                    cell.Append(this.wordTableFormatter.CreateWordTableFromPicklesTable(step.TableArgument));
                }
			}

			cell.Append(CreateNormalParagraph("")); // Is there a better way to generate a new empty line?
			row.Append(cell);
			table.Append(row);

			body.Append(table);
		}
开发者ID:testpulse,项目名称:pickles,代码行数:33,代码来源:WordBackgroundFormatter.cs

示例5: Format

        public void Format(Body body, Table table)
        {
            var wordTable = new WordTable();
            wordTable.Append(GenerateTableProperties());
            var headerRow = new TableRow();
            foreach (string cell in table.HeaderRow)
            {
                var wordCell = new TableCell();
                wordCell.Append(new Paragraph(new Run(new Text(cell))));
                headerRow.Append(wordCell);
            }
            wordTable.Append(headerRow);

            foreach (Parser.TableRow row in table.DataRows)
            {
                var wordRow = new TableRow();

                foreach (string cell in row)
                {
                    var wordCell = new TableCell();
                    wordCell.Append(new Paragraph(new Run(new Text(cell))));
                    wordRow.Append(wordCell);
                }

                wordTable.Append(wordRow);
            }

            body.Append(wordTable);
        }
开发者ID:ppnrao,项目名称:pickles,代码行数:29,代码来源:WordTableFormatter.cs

示例6: Format

        public void Format(Body body, Pickles.Parser.Table table)
        {
            WordTable wordTable = new WordTable();
            wordTable.Append(GenerateTableProperties());
            var headerRow = new DocumentFormat.OpenXml.Wordprocessing.TableRow();
            foreach (var cell in table.HeaderRow)
            {
                var wordCell = new DocumentFormat.OpenXml.Wordprocessing.TableCell();
                wordCell.Append(new Paragraph(new Run(new Text(cell))));
                headerRow.Append(wordCell);
            }
            wordTable.Append(headerRow);

            foreach (var row in table.DataRows)
            {
                var wordRow = new DocumentFormat.OpenXml.Wordprocessing.TableRow();

                foreach (var cell in row)
                {
                    var wordCell = new DocumentFormat.OpenXml.Wordprocessing.TableCell();
                    wordCell.Append(new Paragraph(new Run(new Text(cell))));
                    wordRow.Append(wordCell);
                }

                wordTable.Append(wordRow);
            }

            body.Append(wordTable);
        }
开发者ID:hugohaggmark,项目名称:pickles,代码行数:29,代码来源:WordTableFormatter.cs

示例7: Generate

        public byte[] Generate(string examID, out string fileName)
        {
            string cmdText;

            //checking whether the examid exists
            if (examID == null)
                examID = "";
            if (examID != "")
            {
                cmdText = "SELECT ExamID FROM Exam WHERE ExamID = " + examID;
                object retValue = DBUtil.ExecuteScalar(cmdText);
                if (retValue == null)
                    examID = "";
            }

            if (examID == "")
                throw new ApplicationException("Invalid Exam Notes");

            //getting the Exam details from database
            cmdText = "SELECT p.FirstName + ' ' + p.LastName as PatientName, ExamDate, ExamText, DateOfBirth, u.FirstName + ' ' + u.LastName as DoctorName FROM Patient p JOIN EXAM e on e.PatientID = p.PatientID JOIN [User] u ON u.UserName = e.UserName WHERE ExamID = " + examID;
            SqlDataReader drExam = DBUtil.ExecuteReader(cmdText);

            drExam.Read();
            DateTime dtExam = Convert.ToDateTime(drExam["ExamDate"]);
            DateTime dob = Convert.ToDateTime(drExam["DateOfBirth"]);
            fileName = drExam["PatientName"].ToString() + " - " + dtExam.ToString("yyyyMMdd");
            string xml = drExam["ExamText"].ToString();
            string examDate = dtExam.ToShortDateString();
            string doctorName = drExam["DoctorName"].ToString();

            drExam.Close();
            drExam.Dispose();

            using (MemoryStream ms = new MemoryStream())
            {

                using (WordprocessingDocument package = WordprocessingDocument.Create(ms, WordprocessingDocumentType.Document))
                {

                    MainDocumentPart mainPart = package.AddMainDocumentPart();
                    mainPart.Document = new Document();
                    body = new Body();
                    SectionProperties secprop = new SectionProperties();
                    PageMargin pm = new PageMargin() { Top = 395, Right = 395, Bottom = 395, Left = 395 };
                    secprop.Append(pm);
                    body.Append(secprop);

                    mainPart.Document.Append(body);
                    //mainPart.Document.Descendants<PageMargin>().First();

                    LetterHeader(package);
                    GetLetter(xml, dtExam, dob, doctorName);

                    package.Close();

                }

                return ms.ToArray();
            }
        }
开发者ID:prasannapattam,项目名称:epos,代码行数:60,代码来源:PatientLetter.cs

示例8: Write

        public MemoryStream Write(object data)
        {
            MemoryStream ms;
            using (ms = new MemoryStream())
            {
                using (var wordDocument = WordprocessingDocument.Create(ms, WordprocessingDocumentType.Document))
                {
                    var mainPart = wordDocument.AddMainDocumentPart();
                    mainPart.Document = new Document();

                    List<Trips> tripses = (List<Trips>)data;
                    Table table = this.BuildTable(tripses);

                    var body = new Body();
                    body.Append(table);
                    mainPart.Document.Append(body);

                    var headerPart = mainPart.AddNewPart<HeaderPart>("r97");
                    DateTime dateTime = DateTime.UtcNow;
                    headerPart.Header = this.GetHeader(String.Format("{0} {1}",
                        dateTime, "#"));
                    var sectionProperties1 = mainPart.Document.Body.Descendants<SectionProperties>().FirstOrDefault();
                    if (sectionProperties1 == null)
                    {
                        sectionProperties1 = new SectionProperties() { };
                        mainPart.Document.Body.Append(sectionProperties1);
                    }
                    var headerReference1 = new HeaderReference() { Type = HeaderFooterValues.Default, Id = "r97" };
                    sectionProperties1.InsertAt(headerReference1, 0);
                }
            }

            return ms;
        }
开发者ID:pavelkasyanov,项目名称:KapitanTestTask,代码行数:34,代码来源:TripsDocxReportWriter.cs

示例9: Format

        public void Format(Body body, Step step)
        {
            var paragraph = GenerateStepParagraph(step);
            body.Append(paragraph);

            if (!string.IsNullOrEmpty(step.DocStringArgument))
            {
                string[] lines = step.DocStringArgument.Split(new[] { Environment.NewLine },
                                                              StringSplitOptions.RemoveEmptyEntries);
                foreach (string line in lines)
                {
                    body.GenerateParagraph(line, "Quote");
                }
            }

            if (step.TableArgument != null)
            {
                this.wordTableFormatter.Format(body, step.TableArgument);
            }
        }
开发者ID:Jaykul,项目名称:pickles,代码行数:20,代码来源:WordStepFormatter.cs

示例10: WriteChoicesResponse

        private void WriteChoicesResponse(Body body, QuestionVM question)
        {
            ResponseVM response = question.Response;
            ChoicesLayoutVM choicesLayout = (ChoicesLayoutVM)response.Layout;
            List<CodeVM> validCodes = GetValidCodes(response.Codes);

            if (choicesLayout.MeasurementMethod == ChoicesLayoutMesurementMethod.Single
                || choicesLayout.MeasurementMethod == ChoicesLayoutMesurementMethod.Multiple)
            {
                //測定法が単一回答か多重回答の場合
                Table table = CreateFilledTable(choicesLayout.Surround, false);
                List<List<CodeVM>> codesList = SplitCodes(validCodes, choicesLayout);

                //縦向きの場合(splitCount=列数となる)
                TableRow tableRow = new TableRow();
                table.Append(tableRow);
                int firstCodesCount = codesList[0].Count; //セル中のパラグラフ数をあわせるため(レイアウト枠を表示するため)に最後の列では空パラグラフを追加する。
                foreach (List<CodeVM> codes in codesList)
                {
                    TableCell cell = CreateChoicesCell(codes, firstCodesCount);
                    tableRow.Append(cell);
                }
                body.Append(table);
            }
            else
            {
                //意味微分法(SD法の場合)
                Table table = CreateFilledTable(true, true);

                TableRow tableRow1 = new TableRow();
                TableRow tableRow2 = new TableRow();
                table.Append(tableRow1);
                table.Append(tableRow2);
                foreach (CodeVM code in validCodes)
                {
                    tableRow1.Append(CreateCenterCell(code.Value));
                    tableRow2.Append(CreateCenterCell(code.Label));
                }

                body.Append(table);

            }
        }
开发者ID:Easy-DDI-Organizer,项目名称:EDO,代码行数:43,代码来源:QuestionnaireWriter.cs

示例11: WriteDateTimeResponse

        private void WriteDateTimeResponse(Body body, QuestionVM question)
        {
            ResponseVM response = question.Response;
            DateTimeLayoutVM dateTimeLayout = (DateTimeLayoutVM)response.Layout;

            Table table = CreateFilledTable();

            string prefix = null;
            if (HasRange(response))
            {
                prefix = Resources.FromTo;
            }

            if (config.IsLanguageEn)
            {
                TableRow row1 = CreateDateTimeResponseRowEn(question, prefix);
                table.Append(row1);
                if (HasRange(response))
                {
                    TableRow row2 = CreateDateTimeResponseRowEn(question, " ");
                    table.Append(row2);
                }
            }
            else
            {
                TableRow row1 = CreateDateTimeResponseRowJa(question, prefix);
                table.Append(row1);
                if (HasRange(response))
                {
                    TableRow row2 = CreateDateTimeResponseRowJa(question, " ");
                    table.Append(row2);
                }
            }

            body.Append(table);
        }
开发者ID:Easy-DDI-Organizer,项目名称:EDO,代码行数:36,代码来源:QuestionnaireWriter.cs

示例12: WriteQuestionGroupResponse

        private void WriteQuestionGroupResponse(Body body, QuestionGroupVM questionGroup)
        {
            ICollection<QuestionVM> questions = questionGroup.Questions;
            if (questions.Count == 0)
            {
                return;
            }

            Table table = CreateFilledTable(true, true);

            if (questionGroup.Orientation == QuestionGroupOrientation.Row)
            {
                //行方向の場合(選択肢が横に並んでいる)
                QuestionVM firstQuestion = questions.First();
                List<CodeVM> codes = GetValidCodes(firstQuestion.Response.Codes);
                int firstQuestionCount = codes.Count;

                TableRow tableRow = null;
                if (questionGroup.Sentence == QuestionGroupSentence.Top)
                {
                    //ヘッダー行
                    tableRow = new TableRow();
                    table.Append(tableRow);
                    tableRow.Append(CreateBorderCell(0));
                    foreach (CodeVM code in codes)
                    {
                        tableRow.Append(CreateBorderCell(code.Label));
                    }
                }

                foreach (QuestionVM question in questions)
                {
                    tableRow = new TableRow();
                    table.Append(tableRow);
                    //最初に質問文
                    tableRow.Append(CreateBorderCell(question.Title));
                    //その後にセル
                    codes = GetValidCodes(question.Response.Codes);
                    foreach (CodeVM code in codes)
                    {
                        List<string> contents = new List<string>();
                        contents.Add(code.Value);
                        if (questionGroup.Sentence == QuestionGroupSentence.EachCell)
                        {
                            contents.Add(code.Label);
                        }
                        tableRow.Append(CreateCenterCell(contents));
                    }
                    int diff = firstQuestionCount - codes.Count;
                    if (diff > 0)
                    {
                        for (int i = 0; i < diff; i++)
                        {
                            tableRow.Append(CreateBorderCell(0));
                        }
                    }
                }
            }
            else
            {
                //列方向の場合

                //ヘッダー行
                TableRow tableRow = new TableRow();
                table.Append(tableRow);
                if (questionGroup.Sentence == QuestionGroupSentence.Top)
                {
                    tableRow.Append(CreateBorderCell(0));
                }

                //質問文
                foreach (QuestionVM question in questions)
                {
                    tableRow.Append(CreateBorderCell(question.Title));
                }

                QuestionVM firstQuestion = questions.First();
                List<CodeVM> codes = GetValidCodes(firstQuestion.Response.Codes);
                int firstQuestionCount = codes.Count;

                int codeIndex = 0;
                foreach (CodeVM code in codes)
                {
                    tableRow = new TableRow();
                    table.Append(tableRow);

                    //選択肢
                    if (questionGroup.Sentence == QuestionGroupSentence.Top)
                    {
                        tableRow.Append(CreateBorderCell(code.Label));
                    }

                    foreach (QuestionVM question in questions)
                    {
                        List<CodeVM> questionCodes = GetValidCodes(question.Response.Codes);
                        if (codeIndex < questionCodes.Count)
                        {
                            List<string> contents = new List<string>();
                            contents.Add(questionCodes[codeIndex].Value);
                            if (questionGroup.Sentence == QuestionGroupSentence.EachCell)
//.........这里部分代码省略.........
开发者ID:Easy-DDI-Organizer,项目名称:EDO,代码行数:101,代码来源:QuestionnaireWriter.cs

示例13: WriteBody

        protected override void WriteBody(Body body)
        {
            ObservableCollection<ConstructVM> constructs = controlConstructScheme.Constructs;
            foreach (ConstructVM construct in constructs)
            {
                if (construct is QuestionConstructVM)
                {
                    //質問の書き出し
                    QuestionConstructVM questionConstruct = (QuestionConstructVM)construct;

                    //タイトル
                    string text = questionConstruct.No + ". " + questionConstruct.Text;
                    Paragraph paragraph = CreateMidashi1Paragraph(text);
                    body.Append(paragraph);
                    paragraph = CreateEmptyParagraph();
                    body.Append(paragraph);

                    //回答欄
                    QuestionVM question = questionConstruct.Question;
                    if (question.IsResponseTypeChoices)
                    {
                        WriteChoicesResponse(body, question);
                    } else if (question.IsResponseTypeFree)
                    {
                        WriteFreeResponse(body, question);
                    } else if (question.IsResponseTypeDateTime)
                    {
                        WriteDateTimeResponse(body, question);
                    }
                    else if (question.IsResponseTypeNumber)
                    {
                        WriteNumerResponse(body, question);
                    }
                    paragraph = CreateEmptyParagraph();
                    body.Append(paragraph);
                }
                else if (construct is StatementVM)
                {
                    //説明文の書き出し
                    StatementVM statement = (StatementVM)construct;
                    Paragraph paragraph = CreateParagraph(statement.Text);
                    body.Append(paragraph);
                    paragraph = CreateEmptyParagraph();
                    body.Append(paragraph);

                }
                else if (construct is QuestionGroupConstructVM)
                {
                    //質問グループの書き出し

                    QuestionGroupConstructVM questionGroupConstruct = (QuestionGroupConstructVM)construct;
                    QuestionGroupVM questionGroup = questionGroupConstruct.QuestionGroup;

                    string text = questionGroupConstruct.No + ". " + questionGroupConstruct.Title;
                    Paragraph paragraph = CreateParagraph(text);
                    body.Append(paragraph);
                    paragraph = CreateEmptyParagraph();
                    body.Append(paragraph);

                    WriteQuestionGroupResponse(body, questionGroup);
                    paragraph = CreateEmptyParagraph();
                    body.Append(paragraph);
                }
            }
        }
开发者ID:Easy-DDI-Organizer,项目名称:EDO,代码行数:65,代码来源:QuestionnaireWriter.cs

示例14: GenerateMainDocumentPart1Content

        // Generates content of mainDocumentPart1.
        private void GenerateMainDocumentPart1Content(MainDocumentPart mainDocumentPart1, objPatientContract obj)
        {
            Document document1 = new Document() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "w14 wp14" } };
            document1.AddNamespaceDeclaration("wpc", "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
            document1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            document1.AddNamespaceDeclaration("o", "urn:schemas-microsoft-com:office:office");
            document1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            document1.AddNamespaceDeclaration("m", "http://schemas.openxmlformats.org/officeDocument/2006/math");
            document1.AddNamespaceDeclaration("v", "urn:schemas-microsoft-com:vml");
            document1.AddNamespaceDeclaration("wp14", "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
            document1.AddNamespaceDeclaration("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
            document1.AddNamespaceDeclaration("w10", "urn:schemas-microsoft-com:office:word");
            document1.AddNamespaceDeclaration("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
            document1.AddNamespaceDeclaration("w14", "http://schemas.microsoft.com/office/word/2010/wordml");
            document1.AddNamespaceDeclaration("wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
            document1.AddNamespaceDeclaration("wpi", "http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
            document1.AddNamespaceDeclaration("wne", "http://schemas.microsoft.com/office/word/2006/wordml");
            document1.AddNamespaceDeclaration("wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape");

            Body body1 = new Body();

            Paragraph paragraph1 = new Paragraph() { RsidParagraphAddition = "00900A10", RsidParagraphProperties = "00900A10", RsidRunAdditionDefault = "00900A10" };

            ParagraphProperties paragraphProperties1 = new ParagraphProperties();
            WidowControl widowControl1 = new WidowControl() { Val = false };
            AutoSpaceDE autoSpaceDE1 = new AutoSpaceDE() { Val = false };
            AutoSpaceDN autoSpaceDN1 = new AutoSpaceDN() { Val = false };
            AdjustRightIndent adjustRightIndent1 = new AdjustRightIndent() { Val = false };
            SpacingBetweenLines spacingBetweenLines1 = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };

            ParagraphMarkRunProperties paragraphMarkRunProperties1 = new ParagraphMarkRunProperties();
            RunFonts runFonts1 = new RunFonts() { Ascii = "New Roman", HighAnsi = "New Roman", EastAsia = "New Roman", ComplexScript = "Times New Roman" };
            FontSize fontSize1 = new FontSize() { Val = "24" };
            FontSizeComplexScript fontSizeComplexScript1 = new FontSizeComplexScript() { Val = "24" };

            paragraphMarkRunProperties1.Append(runFonts1);
            paragraphMarkRunProperties1.Append(fontSize1);
            paragraphMarkRunProperties1.Append(fontSizeComplexScript1);

            paragraphProperties1.Append(widowControl1);
            paragraphProperties1.Append(autoSpaceDE1);
            paragraphProperties1.Append(autoSpaceDN1);
            paragraphProperties1.Append(adjustRightIndent1);
            paragraphProperties1.Append(spacingBetweenLines1);
            paragraphProperties1.Append(paragraphMarkRunProperties1);

            paragraph1.Append(paragraphProperties1);

            Paragraph paragraph2 = new Paragraph() { RsidParagraphAddition = "00900A10", RsidParagraphProperties = "00900A10", RsidRunAdditionDefault = "00900A10" };

            ParagraphProperties paragraphProperties2 = new ParagraphProperties();
            WidowControl widowControl2 = new WidowControl() { Val = false };
            AutoSpaceDE autoSpaceDE2 = new AutoSpaceDE() { Val = false };
            AutoSpaceDN autoSpaceDN2 = new AutoSpaceDN() { Val = false };
            AdjustRightIndent adjustRightIndent2 = new AdjustRightIndent() { Val = false };
            SpacingBetweenLines spacingBetweenLines2 = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };

            ParagraphMarkRunProperties paragraphMarkRunProperties2 = new ParagraphMarkRunProperties();
            RunFonts runFonts2 = new RunFonts() { Ascii = "New Roman", HighAnsi = "New Roman", EastAsia = "New Roman", ComplexScript = "Times New Roman" };
            FontSize fontSize2 = new FontSize() { Val = "24" };
            FontSizeComplexScript fontSizeComplexScript2 = new FontSizeComplexScript() { Val = "24" };

            paragraphMarkRunProperties2.Append(runFonts2);
            paragraphMarkRunProperties2.Append(fontSize2);
            paragraphMarkRunProperties2.Append(fontSizeComplexScript2);

            paragraphProperties2.Append(widowControl2);
            paragraphProperties2.Append(autoSpaceDE2);
            paragraphProperties2.Append(autoSpaceDN2);
            paragraphProperties2.Append(adjustRightIndent2);
            paragraphProperties2.Append(spacingBetweenLines2);
            paragraphProperties2.Append(paragraphMarkRunProperties2);

            paragraph2.Append(paragraphProperties2);

            Paragraph paragraph3 = new Paragraph() { RsidParagraphAddition = "00900A10", RsidParagraphProperties = "00900A10", RsidRunAdditionDefault = "00900A10" };

            ParagraphProperties paragraphProperties3 = new ParagraphProperties();
            WidowControl widowControl3 = new WidowControl() { Val = false };
            AutoSpaceDE autoSpaceDE3 = new AutoSpaceDE() { Val = false };
            AutoSpaceDN autoSpaceDN3 = new AutoSpaceDN() { Val = false };
            AdjustRightIndent adjustRightIndent3 = new AdjustRightIndent() { Val = false };
            SpacingBetweenLines spacingBetweenLines3 = new SpacingBetweenLines() { After = "0", Line = "240", LineRule = LineSpacingRuleValues.Auto };
            Justification justification1 = new Justification() { Val = JustificationValues.Center };

            ParagraphMarkRunProperties paragraphMarkRunProperties3 = new ParagraphMarkRunProperties();
            RunFonts runFonts3 = new RunFonts() { Ascii = "Verdana", HighAnsi = "Verdana", EastAsia = "New Roman", ComplexScript = "Verdana" };
            FontSize fontSize3 = new FontSize() { Val = "20" };
            FontSizeComplexScript fontSizeComplexScript3 = new FontSizeComplexScript() { Val = "20" };

            paragraphMarkRunProperties3.Append(runFonts3);
            paragraphMarkRunProperties3.Append(fontSize3);
            paragraphMarkRunProperties3.Append(fontSizeComplexScript3);

            paragraphProperties3.Append(widowControl3);
            paragraphProperties3.Append(autoSpaceDE3);
            paragraphProperties3.Append(autoSpaceDN3);
            paragraphProperties3.Append(adjustRightIndent3);
            paragraphProperties3.Append(spacingBetweenLines3);
//.........这里部分代码省略.........
开发者ID:rymbln,项目名称:Spec_Soft,代码行数:101,代码来源:GeneratedPatientContract.cs

示例15: HelloWorld

        public  void HelloWorld(string documentFileName) 
        { 
            // Create a Wordprocessing document. 
            using (WordprocessingDocument myDoc = 
                   WordprocessingDocument.Create(_TemplatePath, 
                                 WordprocessingDocumentType.Document)) 
            { 
                // Add a new main document part. 
                MainDocumentPart mainPart = myDoc.AddMainDocumentPart(); 
                //Create Document tree for simple document. 
                mainPart.Document = new Document();
                
                
                StyleDefinitionsPart stylePart = mainPart.AddNewPart<StyleDefinitionsPart>();
                // we have to set the properties
                RunProperties rPr = new RunProperties();
                Color color = new Color() { Val = "FF0000" }; // the color is red
                RunFonts rFont = new RunFonts();
                rFont.Ascii = "Arial"; // the font is Arial
                rPr.Append(color);
                rPr.Append(rFont);
                rPr.Append(new Bold()); // it is Bold
                rPr.Append(new FontSize() { Val = "28" }); //font size (in 1/72 of an inch)
                //creation of a style
                Style style = new Style();
                style.StyleId = "MyHeading1"; //this is the ID of the style
                style.Append(new Name() { Val = "My Heading 1" }); //this is name
                // our style based on Normal style
                style.Append(new BasedOn() { Val = "Heading1" });
                // the next paragraph is Normal type
                style.Append(new NextParagraphStyle() { Val = "Normal" });
                style.Append(rPr);//we are adding properties previously defined
                // we have to add style that we have created to the StylePart
                stylePart.Styles = new Styles();
                stylePart.Styles.Append(style);
                stylePart.Styles.Save(); // we save the style part

                Paragraph heading = new Paragraph();
                Run heading_run = new Run();
                Text heading_text = new Text("This is Heading");
                ParagraphProperties heading_pPr = new ParagraphProperties();
                // we set the style
                heading_pPr.ParagraphStyleId = new ParagraphStyleId() { Val = "MyHeading1" };
                heading.Append(heading_pPr);
                heading_run.Append(heading_text);
                heading.Append(heading_run);


                //Create Body (this element contains
                //other elements that we want to include 
                Body body = new Body(); 
                //Create paragraph 
                Paragraph paragraph = new Paragraph(); 
                Run run_paragraph = new Run(); 
                // we want to put that text into the output document 
                Text text_paragraph = new Text("Hello World!"); 
                //Append elements appropriately. 
                run_paragraph.Append(text_paragraph); 
                paragraph.Append(run_paragraph); 
                body.Append(paragraph);
                body.Append(heading); 
                mainPart.Document.Append(body); 
                // Save changes to the main document part. 
                mainPart.Document.Save(); 
            } 
        
        }
开发者ID:PaoloMisson,项目名称:GATEvolution,代码行数:67,代码来源:Word.cs


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