2010-10-28 42 views

回答

11

查看PdfPTableRows.Add()方法,該方法採用PdfPRow,您可以使用PdfPCells的數組構造該方法。

實施例:

// ... 
PdfPTable table = new PdfPTable(5); 
PdfPCell[] cells = new PdfPCell[] { new PdfPCell(GetCell("c1")), 
            new PdfPCell(GetCell("c2")), 
            new PdfPCell(GetCell("c3")), 
            new PdfPCell(GetCell("c4")), 
            new PdfPCell(GetCell("c5"))}; 
PdfPRow row = new PdfPRow(cells); 
table.Rows.Add(row); 
// ... 

GetCell()哪裏返回PdfPCell的方法。

+0

我更喜歡Kukoy所追求的方法。我嘗試了@Jay Rigg的代碼,但通常以一個錯誤結束,該錯誤表示無法訪問已關閉的文件。問題是根據布魯諾http://stackoverflow.com/a/19874992/97109,iTextSharp不鼓勵這種方法。我想知道爲什麼。 – Stack0verflow 2014-03-19 18:52:43

相關問題