2014-05-14 4 views
0

내 요구 사항에서 단어 문서의 섹션에있는 특정 단락을 반복하고 싶습니다. 여기 워드 문서ASPOSE.DLL을 사용하여 섹션에있는 단락을 반복하는 방법

#Section Start 
1) TO RECEIVE AND ADOPT FINANCIAL STATEMENTS FOR THE YEAR ENDED [FYE] 

a.That the Financial Statements of the Company for the financial year ended [FYE] together with the Director(s)' Report and Statement thereon be hereby received and adopted. 
b. Second paragraph. 
c. Third paragraph. 
#Section End 

이하 나는 아래의 코드

// Copy all content including headers and footers from the specified 
//pages into the destination document. 
       ArrayList pageSections = finder.RetrieveAllNodesOnPages(1, doc.Sections.Count, NodeType.Section); 
       System.Data.DataTable dt = GetDataTable(); //Sample DataTable which is having Keys and Values 
       int sectionCount = 0; 
       foreach (Section section in pageSections) 
       { 

        NodeCollection paragraphs = section.GetChildNodes(NodeType.Paragraph, true); 

        for (int i = 0; i < paragraphs.Count; i++) 
        { 
         string text = paragraphs[i].Range.Text; 

        } 
        } 

를 바랍니다 시도 3 회

에 "A"지점을 반복합니다 같은 부분에서 우리가 단락을 가지고, 섹션으로 나누어 단락을 반복하는 방법을 알려주십시오.

답변

1

저는 Aspose에서 소셜 미디어 개발자로 일하고 있습니다. Aspose.Words for .NET을 사용하여 단락을 반복하려면 다음 샘플 코드를 사용하십시오.

Document doc = new Document("document.docx"); 

PageNumberFinder finder = new PageNumberFinder(doc); 

// Split nodes which are found across pages. 
finder.SplitNodesAcrossPages(true); 

// Copy all content including headers and footers from the specified pages into the         
//destination document. 
ArrayList pageSections = finder.RetrieveAllNodesOnPages(1, doc.Sections.Count, NodeType.Section); 

//Sample DataTable which is having Keys and Values 
System.Data.DataTable dt = GetDataTable(); 

int sectionCount = 0; 

foreach (Section section in pageSections) 
{ 

    NodeCollection paragraphs = section.GetChildNodes(NodeType.Paragraph, true); 

    for (int i = 0; i < paragraphs.Count; i++) 
    {      
     //Paragraph you want to copy 
     if (i == 10) 
     { 

      //Use Document Builder to Navigate to the paragraph 
      DocumentBuilder builder = new DocumentBuilder(doc); 

      builder.MoveTo(paragraphs[i]); 

      //Insert a Paragraph break 
      builder.InsertParagraph(); 

      //Insert the Paragraph to repeat it 
      builder.Writeln(paragraphs[i].ToString(SaveFormat.Text)); 


     } 


    } 

} 

doc.Save("test.docx");