2010-02-23 5 views
0

나는 테이블과 같이 만들려고 : 잘 작동iTextSharp - 테이블 함수의 버그?

PdfPTable Table = new PdfPTable(6); 

PdfPCell Cell = new PdfPCell(new Phrase("a", Font1)); 
Cell.Rowspan = 2; 
Cell.Colspan = 2; 
Table.AddCell(Cell); 

Cell = new PdfPCell(new Phrase("b", Font1)); 
Cell.Rowspan = 2; 
Cell.Colspan = 2; 
Table.AddCell(Cell); 

Cell = new PdfPCell(new Phrase("c", Font1)); 
Cell.Colspan = 2; 
Table.AddCell(Cell); 

Cell = new PdfPCell(new Phrase("d", Font1)); 
Cell.Colspan = 2; 
Table.AddCell(Cell); 

합니다. 그러나 열 수를 변경하면 테이블이 파괴됩니다. 버그입니까? 아니면 뭔가 잘못 됐나요?

PdfPTable Table = new PdfPTable(17); 

PdfPCell Cell = new PdfPCell(new Phrase("a", Font1)); 
Cell.Rowspan = 2; 
Cell.Colspan = 2; 
Table.AddCell(Cell); 

Cell = new PdfPCell(new Phrase("b", Font1)); 
Cell.Rowspan = 2; 
Cell.Colspan = 10; 
Table.AddCell(Cell); 

Cell = new PdfPCell(new Phrase("c", Font1)); 
Cell.Colspan = 5; 
Table.AddCell(Cell); 

Cell = new PdfPCell(new Phrase("d", Font1)); 
Cell.Colspan = 5; 
Table.AddCell(Cell); 

편집 :

|-------------------------------------------------------| 
| Cell "a" with | Cell "b" with | Cell "c", colspan = 5 | 
| colspan = 2 | colspan = 10 |-----------------------| 
| rowspan = 2 | rowspan = 2 | Cell "d", colspan = 5 | 
|-------------------------------------------------------| 
+1

총'colspan'은'PdfPTable' 생성자의 컬럼 인수보다 큽니다 ... 왜 그럴까요? – bzlm

+0

테이블에는 왼쪽에 2 개의 열과 2의 rownspan이 있어야합니다.이 2 개의 셀 오른쪽에 2 개의 셀이 있어야합니다. 그래서 2 개의 오른쪽 셀은 동일한 colspan을 가져야하며 총 colspan 수는 테이블의 열 수보다 큽니다. 나는 이것이 정확하다고 생각한다. – Matthias

답변

1

Table.CompleteRow();으로 마지막 줄을 추가합니다 : 테이블이 레이아웃을 가지고 있어야

이 코드는 테이블을 파괴한다.