Pipo01 Posted June 3, 2014 at 03:47 PM Report #558089 Posted June 3, 2014 at 03:47 PM (edited) boas 🙂 como indica o titulo e isso que eu pretendo... aqui esta o meu codigo de pdf FileStream tix = new FileStream("Relatório.pdf", FileMode.Create); Document documento = new Document(PageSize.A4, 25, 25, 30, 30); PdfWriter escrever = PdfWriter.GetInstance(documento, tix); documento.Open(); PdfPTable tabela = new PdfPTable(dataGridView1.Columns.Count); //add the headers from DGV to the table for (int j = 0; j < dataGridView1.Columns.Count; j++) { tabela.AddCell(new Phrase(dataGridView1.Columns[j].HeaderText)); } //flag the first row as a header tabela.HeaderRows = 1; //add the actual rows from the DGV to the table for (int i = 0; i < dataGridView1.Rows.Count; i++) { for (int k = 0; k <dataGridView1.Columns.Count;k++) { if(dataGridView1[k,i].Value != null) { tabela.AddCell(new Phrase(dataGridView1[k, i].Value.ToString())); } } } documento.Add(tabela); documento.Close(); Edited June 3, 2014 at 03:51 PM by Pipo01
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now