iTextSharp.text.Font fontTable = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK); PdfPTable table = new PdfPTable(dataGridView1.Columns.Count); table.SpacingBefore = 45f; table.TotalWidth = 300; table.DefaultCell.Phrase = new Phrase() { Font = fontTable }; for (int j = 0; j < dataGridView1.Columns.Count; j++) { table.AddCell(new Phrase(dataGridView1.Columns[j].HeaderText, fontTable)); } table.HeaderRows = 1; for (int i = 0; i < dataGridView1.Rows.Count; i++) { for (int k = 0; k < dataGridView1.Columns.Count; k++) { if (dataGridView1[k, i].Value != null) { table.AddCell(new Phrase(dataGridView1[k, i].Value.ToString(),fontTable)); } } } doc.Add(table);
foreach (DataGridViewColumn c in GridView.Columns) { if( c.Name == "Something" ) { //Skip this column continue; } //process these columns //.. } for (int i = 0; i < GridView.Rows.Count - 1; i++) { for (int j = 0; j < GridView.Columns.Count - 1; j++) { if( GridView.Columns[j].Name == "Something" ) { //Skip this column continue } //Process these columns } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)