2010-03-03 44 views
1

我有一些問題,行跨度:iTextSharp的:行跨度不起作用

var doc1 = new Document(); 
     doc1.SetPageSize(PageSize.A4.Rotate()); 
     string path = Server.MapPath("PDFs"); 
     PdfWriter.GetInstance(doc1, new FileStream(path + "/Doc1.pdf", FileMode.Create)); 
     doc1.Open(); 
     PdfPTable table = new PdfPTable(17); 
     PdfPCell cell = new PdfPCell(new Phrase("Missioni aggregato per macro causali")); 
     cell.Colspan = 17; 
     cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right 
     table.AddCell(cell); 
     cell = new PdfPCell(new Phrase("Matricola")); 
     cell.Rowspan = 2; 
     cell.Rotation = 90; 
     table.AddCell(cell); 

     cell = new PdfPCell(new Phrase("Nominativo")); 
     cell.Rowspan = 2; 
     table.AddCell(cell); 

     cell = new PdfPCell(new Phrase("Assegnazione"));    
     cell.Colspan = 2; 
     table.AddCell(cell);    

     cell = new PdfPCell(new Phrase("Riepilogo missioni valori dal ")); 
     cell.Colspan = 13; 
     cell.Rowspan = 2; 
     table.AddCell(cell); 

     cell = new PdfPCell(new Phrase("Struttura"));    
     table.AddCell(cell); 

     cell = new PdfPCell(new Phrase("Ufficio")); 
     table.AddCell(cell); 

細胞「Riepilogo missioni valori DAL」是同一行單元格的「struttura」和細胞中的「UFFICIO」 爲什麼呢?

我該怎麼辦?

感謝

+0

我測試它iTextSharp的7和它的工作原理 – JosefMadrid 2017-02-09 12:13:40

回答

3

你的細胞 「Riepilogo missioni valori DAL」 只有跨越13列。 PdfPTable要求您在當前行的末尾填入其餘的列(4),然後它將跳轉到17列的下一行。

要填充行的末尾,可以添加4個空單元格或使用CompleteRow方法。

table.AddCell("") 
table.AddCell("") 
table.AddCell("") 
table.AddCell("") 

table.CompleteRow()