Tag: itextsharp pdfptable

使用itextsharp将dataGridView转换为pdf

我在尝试获取dataGridView中特定列的值并将它们添加到PdtPtable时遇到问题。 但是重复了表中添加的值,例如第一行添加了两次。我试图遍历每一行和每行中的每一行。 PdfPTable pdfTable= new PdfPTable(5); foreach(DataGridViewRow row in dataGridView1.Rows) { foreach (DataGridViewCell celli in row.Cells) { try { pdfTable.AddCell(celli.Value.ToString()); } catch { } } doc.Add(pdfTable); }