2014-12-26 5 views
1

Novacode.DocX을 사용하면 테이블을 만들고 문서에 삽입하는 것이 쉽습니다.Novacode DocX 코드에서 테이블의 텍스트에 대한 세로 방향을 설정하는 방법은 무엇입니까?

// Create a document. 
using (DocX document = DocX.Create(@"Test.docx")) 
{ 
// Add a Table to this document. 
Table t = document.AddTable(2, 3); 
// Specify some properties for this Table. 
t.Alignment = Alignment.center; 
t.Design = TableDesign.MediumGrid1Accent2; 
// Add content to this Table. 
t.Rows[0].Cells[0].Paragraphs.First().Append("A"); 
t.Rows[0].Cells[1].Paragraphs.First().Append("B"); 
t.Rows[0].Cells[2].Paragraphs.First().Append("C"); 
t.Rows[1].Cells[0].Paragraphs.First().Append("D"); 
t.Rows[1].Cells[1].Paragraphs.First().Append("E"); 
t.Rows[1].Cells[2].Paragraphs.First().Append("F"); 
// Insert the Table into the document. 
document.InsertTable(t); 
document.Save(); 
}// Release this document from memory. 

어떻게 DOCX와 테이블에 텍스트의 수직 방향을 설정하는 아래의 IMAG

그리고, 보이는 문서를 생성합니다 위의 코드? 텍스트 방향은 오른쪽에서 왼쪽으로 또는 그 반대로 만 이루어집니다.

tablePlan.Rows[0].Cells[1].Paragraphs.First().Direction = Direction.LeftToRight; 

아래에서 위로 올려 놓는 방법?

enter image description here

+0

그런데 이미지는 어디에 있습니까? –

+0

그림이 추가되었습니다. – arsenium

답변

0

이 솔루션은 주변의 일이며, 이미 표가 손 전에해야 할 것입니다 열 수를 알고있는 경우에만 작동합니다. 찾고자하는 속성 인 텍스트 방향이 포함 된 문서를 먼저 작성해야합니다. 그런 다음 다른 템플릿 문서에서 필요에 따라 Tables을 가져올 수 있습니다.

// Create a document. 
using (DocX document = DocX.Create(@"Test.docx")) 
{ 
    Table t; 
    using (DocX document2 = DocX.Load(@"Test2.docx")) 
    { 
     t = document2.Tables[0]; 
    }   
    // Specify some properties for this Table. 
    t.Alignment = Alignment.center; 
    t.Design = TableDesign.MediumGrid1Accent2; 
    // Add content to this Table. 
    t.Rows[0].Cells[0].Paragraphs.First().Append("A"); 
    t.Rows[0].Cells[1].Paragraphs.First().Append("B"); 
    t.Rows[0].Cells[2].Paragraphs.First().Append("C"); 
    t.Rows[1].Cells[0].Paragraphs.First().Append("D"); 
    t.Rows[1].Cells[1].Paragraphs.First().Append("E"); 
    t.Rows[1].Cells[2].Paragraphs.First().Append("F"); 
    // Insert the Table into the document. 
    document.InsertTable(t); 
    document.Save(); 
}// Release this document from memory. 

document2에는 찾고있는 속성이 포함 된 표가 포함되어 있습니다.