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


C# DocumentBuilder.MoveToMergeField方法代码示例

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


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

示例1: Run

        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithDocument();
            string fileName = "TestFile.doc";
            Document doc = new Document(dataDir + fileName);

            // Use a document builder to retrieve the field start of a merge field.
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Pass the first boolean parameter to get the DocumentBuilder to move to the FieldStart of the field.
            // We could also get FieldStarts of a field using GetChildNode method as in the other examples.
            builder.MoveToMergeField("Fullname", false, false);

            // The builder cursor should be positioned at the start of the field.
            FieldStart startField = (FieldStart)builder.CurrentNode;
            Paragraph endPara = (Paragraph)doc.FirstSection.GetChild(NodeType.Paragraph, 5, true);

            // Extract the content between these nodes in the document. Don't include these markers in the extraction.
            ArrayList extractedNodes = Common.ExtractContent(startField, endPara, false);

            // Insert the content into a new separate document and save it to disk.
            Document dstDoc = Common.GenerateDocument(doc, extractedNodes);
            dataDir = dataDir +  RunExamples.GetOutputFilePath(fileName);
            dstDoc.Save(dataDir);

            Console.WriteLine("\nExtracted content using the Field successfully.\nFile saved at " + dataDir);
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:28,代码来源:ExtractContentUsingField.cs

示例2: StudentUpdateRecordProcessor

        public StudentUpdateRecordProcessor(DocumentBuilder builder)
        {
            _builder = builder;
            _builder.MoveToMergeField("學籍狀況");

            _cell = _builder.CurrentParagraph.ParentNode as Cell;
        }
开发者ID:ChunTaiChen,项目名称:KaoHsiung.StudentRecordReport,代码行数:7,代码来源:StudentUpdateRecordProcessor.cs

示例3: StudentTextProcessor

 public StudentTextProcessor(DocumentBuilder builder, SemesterMap map)
 {
     _builder = builder;
     _builder.MoveToMergeField("學習領域評量");
     _cell = _builder.CurrentParagraph.ParentNode as Cell;
     _manager = new DomainTextManager();
     _map = map;
 }
开发者ID:ChunTaiChen,项目名称:KaoHsiung.StudentRecordReport,代码行数:8,代码来源:StudentTextProcessor.cs

示例4: StudentSemesterScoreProcessor

 public StudentSemesterScoreProcessor(DocumentBuilder builder, SemesterMap map, string type,Dictionary<string,bool> domains,K12.Data.GradScoreRecord StudGradScore)
 {
     builder.MoveToMergeField("成績");
     _builder = builder;
     _manager = new DomainRowManager( type);
     _cell = builder.CurrentParagraph.ParentNode as Cell;
     _map = map;
     _domains = domains;
     _StudGradScore = StudGradScore;
 }
开发者ID:ChunTaiChen,项目名称:KaoHsiung.StudentRecordReport,代码行数:10,代码来源:StudentSemesterScoreProcessor.cs

示例5: DocumentBuilder

            /// <summary>
            /// This is called when merge field is actually merged with data in the document.
            /// </summary>
            void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
            {
                // All merge fields that expect HTML data should be marked with some prefix, e.g. 'html'.
                if (e.DocumentFieldName.StartsWith("html"))
                {
                    // Insert the text for this merge field as HTML data, using DocumentBuilder.
                    DocumentBuilder builder = new DocumentBuilder(e.Document);
                    builder.MoveToMergeField(e.DocumentFieldName);
                    builder.InsertHtml((string)e.FieldValue);

                    // The HTML text itself should not be inserted.
                    // We have already inserted it as an HTML.
                    e.Text = "";
                }
            }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:18,代码来源:ExMailMergeEvent.cs

示例6: DocumentBuilder

        void IFieldMergingCallback.FieldMerging(FieldMergingArgs e) {
            if (e.FieldValue == null) {
                return;
            }

            if (!e.FieldValue.ToString().StartsWith("<table") && !e.FieldValue.ToString().StartsWith("<html")) {
                e.Text = e.FieldValue.ToString();
                return;
            }

            var builder = new DocumentBuilder(e.Document);

            builder.MoveToMergeField(e.DocumentFieldName);

            builder.InsertHtml((string)e.FieldValue);

            e.Text = "";
        }
开发者ID:shawn-freeman,项目名称:HRSG_Generator_Repo,代码行数:18,代码来源:MailMergeFieldHandler.cs

示例7: SetDocument

        // WORD處理
        private Document SetDocument(ClassTotalObj aClass)
        {
            StringBuilder WarningStudents = new StringBuilder();

            // 取得班級中所有學生清單
            List<StudentTotalObj> studentObjList = new List<StudentTotalObj>(aClass.StudentDic.Values);
            
            //排序
            studentObjList.Sort(SortStudent);

            Document PageOne = (Document)_template.Clone(true);
            _run = new Run(PageOne);
            DocumentBuilder builder = new DocumentBuilder(PageOne);

            int columnCount = aClass.SLRSchoolYearSemesterDic.Count;
            int columnIndex = 1;

            // 文件移到學年度跟學期的標題
            builder.MoveToMergeField("學年度"); // 移到有學年度的標籤上
            Cell cellSchoolYear = (Cell)builder.CurrentParagraph.ParentNode;

            // 準備學年度跟學期的標題
            List<string> SchoolYearSemesterList = new List<string>(aClass.SLRSchoolYearSemesterDic.Keys);

            // 排序
            SchoolYearSemesterList.Sort(SortSchoolYearSemester);

            // 取得學年度跟學期的欄位數量
            _MAX_COLUMN_COUNT = GetRemainColumn(cellSchoolYear);

            // 確保資料的數量跟欄位一致
            if (SchoolYearSemesterList.Count > _MAX_COLUMN_COUNT)
            {
                int delCount = SchoolYearSemesterList.Count - _MAX_COLUMN_COUNT;
                for(int intI=0; intI<delCount; intI++)
                {
                    SchoolYearSemesterList.RemoveAt(0);
                }
            }

            // 輸出學年度跟學期的標題
            foreach (string each in SchoolYearSemesterList)
            {
                // 學年度
                Write(cellSchoolYear, each);

                // 不是最後一筆資料的話, 就移到下一個cell
                if(columnIndex < columnCount)
                {
                    cellSchoolYear = GetMoveRightCell(cellSchoolYear, 1);
                }
                columnIndex++;
            }
            

            builder.MoveToMergeField("資料"); // 移到有資料的標籤上
            Cell cell = (Cell)builder.CurrentParagraph.ParentNode;

            //需要Insert Row
            //取得目前Row
            Row 日3row = (Row)cell.ParentRow;

            for (int x = 1; x < studentObjList.Count; x++)
            {
                cell.ParentRow.ParentTable.InsertAfter(日3row.Clone(true), cell.ParentNode);
            }

            //學生ID
            foreach (StudentTotalObj student in studentObjList)
            {
                // 用來計算輸出了幾次學年度跟學期的服務時數
                int SLROutputCount = 0;

                // 座號
                Write(cell, student.seat_no);
                cell = GetMoveRightCell(cell, 1);
                
                // 姓名
                Write(cell, student.student_name);
                cell = GetMoveRightCell(cell, 1);
                
                // 學號
                Write(cell, student.student_number);
                cell = GetMoveRightCell(cell, 1);
                
                // 性別
                Write(cell, student.student_gender);
                cell = GetMoveRightCell(cell, 1);
                
                // 學習時數
                columnCount = SchoolYearSemesterList.Count;
                columnIndex = 1;
                foreach(string each in SchoolYearSemesterList)
                {
                    if (student.SLRDic.ContainsKey(each))
                    {
                        Write(cell, student.SLRDic[each].ToString());
                        SLROutputCount++;
                    }
//.........这里部分代码省略.........
开发者ID:redolin,项目名称:K12.Service.Learning.SLRMultiReport,代码行数:101,代码来源:SLRClassTotalMulti.cs

示例8: FillingDocument

        public void FillingDocument()
        {
            //ExStart
            //ExFor:DocumentBuilder.MoveToMergeField(string)
            //ExFor:DocumentBuilder.Bold
            //ExFor:DocumentBuilder.Italic
            //ExSummary:Fills document merge fields with some data.
            Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "DocumentBuilder.FillingDocument.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.MoveToMergeField("TeamLeaderName");
            builder.Bold = true;
            builder.Writeln("Roman Korchagin");

            builder.MoveToMergeField("SoftwareDeveloper1Name");
            builder.Italic = true;
            builder.Writeln("Dmitry Vorobyev");

            builder.MoveToMergeField("SoftwareDeveloper2Name");
            builder.Italic = true;
            builder.Writeln("Vladimir Averkin");

            doc.Save(ExDir + "DocumentBuilder.FillingDocument Out.doc");
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:25,代码来源:ExDocumentBuilder.cs

示例9: DocumentBuilderMoveToMergeField

        public void DocumentBuilderMoveToMergeField()
        {
            //ExStart
            //ExId:DocumentBuilderMoveToMergeField
            //ExSummary:Shows how to move the cursor to a position just beyond the specified merge field.
            Aspose.Words.Document doc = new Aspose.Words.Document(ExDir + "DocumentBuilder.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.MoveToMergeField("NiceMergeField");
            builder.Writeln("This is a very nice merge field.");
            //ExEnd
        }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:12,代码来源:ExDocumentBuilder.cs

示例10: MoveToMergeField

        public static void MoveToMergeField(string dataDir)
        {
            // ExStart:DocumentBuilderMoveToMergeField
            Document doc = new Document(dataDir + "DocumentBuilder.doc");
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.MoveToMergeField("NiceMergeField");
            builder.Writeln("This is a very nice merge field.");
            // ExEnd:DocumentBuilderMoveToMergeField              
        }     
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:10,代码来源:DocumentBuilderMovingCursor.cs

示例11: MailMerge_MergeField

        void MailMerge_MergeField(object sender, Aspose.Words.Reporting.MergeFieldEventArgs e)
        {
            if (e.FieldName == "班級資料")
            {
                Document PageOne = e.Document; // (Document)_template.Clone(true);
                _run = new Run(PageOne);
                DocumentBuilder builder = new DocumentBuilder(PageOne);
                builder.MoveToMergeField("班級資料");
                ////取得目前Cell
                Cell cell = (Cell)builder.CurrentParagraph.ParentNode;
                ////取得目前Row
                Row row = (Row)builder.CurrentParagraph.ParentNode.ParentNode;

                //建立新行
                for (int x = 1; x < bot.ClassDic.Count; x++)
                {
                    (cell.ParentNode.ParentNode as Table).InsertAfter(row.Clone(true), cell.ParentNode);
                }

                foreach (string each in bot.ClassDic.Keys)
                {
                    Write(cell, bot.ClassDic[each]._class);
                    if (cell.NextSibling != null) //是否最後一格
                        cell = cell.NextSibling as Cell; //下一格

                    Write(cell, bot.ClassDic[each]._班級人數);
                    if (cell.NextSibling != null) //是否最後一格
                        cell = cell.NextSibling as Cell; //下一格

                    Write(cell, bot.ClassDic[each]._teacher);
                    if (cell.NextSibling != null) //是否最後一格
                        cell = cell.NextSibling as Cell; //下一格

                    Write(cell, tool.GetAwayZero(bot.ClassDic[each].班級校內時數).ToString());
                    if (cell.NextSibling != null) //是否最後一格
                        cell = cell.NextSibling as Cell; //下一格

                    Write(cell, tool.GetAwayZero(bot.ClassDic[each].班級校外時數).ToString());
                    if (cell.NextSibling != null) //是否最後一格
                        cell = cell.NextSibling as Cell; //下一格

                    Write(cell, tool.GetAwayZero(bot.ClassDic[each].班級服務總時數).ToString());
                    if (cell.NextSibling != null) //是否最後一格
                        cell = cell.NextSibling as Cell; //下一格

                    Row Nextrow = cell.ParentRow.NextSibling as Row; //取得下一個Row
                    if (Nextrow == null)
                        break;
                    cell = Nextrow.FirstCell; //第一格Cell  
                }
            }
            else if (e.FieldName == "主辦單位資料")
            {
                Document PageOne = e.Document; // (Document)_template.Clone(true);
                _run = new Run(PageOne);
                DocumentBuilder builder = new DocumentBuilder(PageOne);
                builder.MoveToMergeField("主辦單位資料");
                ////取得目前Cell
                Cell cell = (Cell)builder.CurrentParagraph.ParentNode;
                ////取得目前Row
                Row row = (Row)builder.CurrentParagraph.ParentNode.ParentNode;

                //建立新行
                for (int x = 1; x < bot.OrganizersDic.Count; x++)
                {
                    (cell.ParentNode.ParentNode as Table).InsertAfter(row.Clone(true), cell.ParentNode);
                }

                foreach (string each in bot.OrganizersDic.Keys)
                {
                    Write(cell, bot.OrganizersDic[each]._Organizers);
                    if (cell.NextSibling != null) //是否最後一格
                        cell = cell.NextSibling as Cell; //下一格

                    Write(cell, bot.OrganizersDic[each]._InternalExternal);
                    if (cell.NextSibling != null) //是否最後一格
                        cell = cell.NextSibling as Cell; //下一格

                    Write(cell, tool.GetAwayZero(bot.OrganizersDic[each]._AllCount).ToString());
                    if (cell.NextSibling != null) //是否最後一格
                        cell = cell.NextSibling as Cell; //下一格

                    Row Nextrow = cell.ParentRow.NextSibling as Row; //取得下一個Row
                    if (Nextrow == null)
                        break;
                    cell = Nextrow.FirstCell; //第一格Cell  
                }
            }

        }
开发者ID:dylan2013,项目名称:MOD_Service.Learning.Shinmin,代码行数:90,代码来源:LearningSchoolStatistics.cs

示例12: DocumentBuilder

            /// <summary>
            /// This handler makes special processing for the "Document_1" field.
            /// The field value contains the path to load the document. 
            /// We load the document and insert it into the current merge field.
            /// </summary>
            void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
            {
                if (e.DocumentFieldName == "Document_1")
                {
                    // Use document builder to navigate to the merge field with the specified name.
                    DocumentBuilder builder = new DocumentBuilder(e.Document);
                    builder.MoveToMergeField(e.DocumentFieldName);

                    // The name of the document to load and insert is stored in the field value.
                    Aspose.Words.Document subDoc = new Aspose.Words.Document((string)e.FieldValue);

                    // Insert the document.
                    InsertDocument(builder.CurrentParagraph, subDoc);

                    // The paragraph that contained the merge field might be empty now and you probably want to delete it.
                    if (!builder.CurrentParagraph.HasChildNodes)
                        builder.CurrentParagraph.Remove();

                    // Indicate to the mail merge engine that we have inserted what we wanted.
                    e.Text = null;
                }
            }
开发者ID:joyang1,项目名称:Aspose_Words_NET,代码行数:27,代码来源:ExInsertDocument.cs

示例13: ExtractContentUsingField

        public static void ExtractContentUsingField()
        {
            //ExStart
            //ExFor:DocumentBuilder.MoveToMergeField(String, Boolean, Boolean)
            //ExId:ExtractBetweenNodes_UsingField
            //ExSummary:Shows how to extract content between a specific field and paragraph in the document using the ExtractContent method.
            // Load in the document
            Document doc = new Document(mDataDir + "TestFile.doc");

            // Use a document builder to retrieve the field start of a merge field.
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Pass the first boolean parameter to get the DocumentBuilder to move to the FieldStart of the field.
            // We could also get FieldStarts of a field using GetChildNode method as in the other examples.
            builder.MoveToMergeField("Fullname", false, false);

            // The builder cursor should be positioned at the start of the field.
            FieldStart startField = (FieldStart)builder.CurrentNode;
            Paragraph endPara = (Paragraph)doc.FirstSection.GetChild(NodeType.Paragraph, 5, true);

            // Extract the content between these nodes in the document. Don't include these markers in the extraction.
            ArrayList extractedNodes = ExtractContent(startField, endPara, false);

            // Insert the content into a new separate document and save it to disk.
            Document dstDoc = GenerateDocument(doc, extractedNodes);
            dstDoc.Save(mDataDir + "TestFile.Fields Out.pdf");
            //ExEnd
        }
开发者ID:nancyeiceblue,项目名称:Aspose_Words_NET,代码行数:28,代码来源:Program.cs

示例14: ExecuteWithOnceImageRegions

        public static void ExecuteWithOnceImageRegions(DataSet InputDataSet, string serverpath)
        {
            string m_Colname = "";
            string m_FieldValue = "";
            DataTable tbl = new DataTable();
            if (_oWord == null)
                return;
            DocumentBuilder builder = new DocumentBuilder(_oWord);
            tbl.Columns.Add("Image1");

            foreach (DataTable table in InputDataSet.Tables)
            {
                if (table.TableName != null && table.TableName != "")
                {
                    foreach (DataRow row in table.Rows)
                    {
                        DataRow dr = tbl.NewRow();
                        for (int i = 0; i <= table.Columns.Count - 1; i++)
                        {
                            m_Colname = table.Columns[i].ColumnName;
                            m_FieldValue = row[m_Colname].ToString();
                            if (m_Colname == "ImagePath")
                            {
                                dr["Image1"] = m_FieldValue;
                            }

                        }
                        tbl.Rows.Add(dr);
                    }
                    _oWord.MailMerge.ExecuteWithRegions(table);
                }
            }

            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                if (tbl.Rows[i][0].ToString() != "" && File.Exists(serverpath + tbl.Rows[i][0].ToString()))
                {
                    InsertImage("Image1", serverpath + tbl.Rows[i][0].ToString());
                }
                else
                {
                    builder.MoveToMergeField("Image1");
                    // builder.Write("");
                    // builder.Write("Hình 3 x 4");
                }

            }


        }
开发者ID:dtafe,项目名称:vnr,代码行数:50,代码来源:ExportHelper.cs

示例15: MergeFieldWithImageRescaling

        public static void MergeFieldWithImageRescaling(DataTable InputTable, string ImageFieldName)
        {
            try
            {
                string m_Colname = "";
                string m_FieldValue = "";
                List<string> LstImagePath = new List<string>();
                foreach (DataRow row in InputTable.Rows)
                {
                    for (int i = 0; i <= InputTable.Columns.Count - 1; i++)
                    {
                        m_Colname = InputTable.Columns[i].ColumnName;
                        m_FieldValue = row[m_Colname].ToString();
                        if (m_Colname != ImageFieldName)
                        {
                            m_FieldValue = m_FieldValue.Replace("\r\n", "XXXXXX");
                            m_FieldValue = m_FieldValue.Replace("\n\r", "XXXXXX");
                            m_FieldValue = m_FieldValue.Replace("\n", "XXXXXX");
                            m_FieldValue = m_FieldValue.Replace("\r", "XXXXXX");
                            row[m_Colname] = m_FieldValue;
                            _oWord.Range.Replace("[" + m_Colname + "]", m_FieldValue, false, false);
                        }
                        else
                        {
                            if (m_FieldValue[m_FieldValue.Length - 1].ToString() == "/")
                            {
                                DocumentBuilder builder = new DocumentBuilder(_oWord);
                                builder.MoveToMergeField(ImageFieldName);
                                builder.Write("Hình 3 x 4");
                            }
                            else
                            {
                                InsertImage(ImageFieldName, m_FieldValue);
                            }

                        }

                    }
                }
                _oWord.Range.Replace("XXXXXX", Aspose.Words.ControlChar.LineBreakChar.ToString(), false, false);
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:46,代码来源:ExportHelper.cs


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