As I said before, if there is empty in the datagridview-cell, the type of this cell is null, so the reason of this error message is there are some empty cells and I guess they belong to the last line. But I guess maybe not only the last line is empty, other cells may also be empty, so you can determine whether it is empty and if so, replace it with a specific character:. This can be beneficial to other community members reading this thread. You only output data for each row of cells in datagridview without outputting the data for each column header, I suggest you can add it:.
|Published (Last):||15 December 2013|
|PDF File Size:||3.72 Mb|
|ePub File Size:||9.26 Mb|
|Price:||Free* [*Free Regsitration Required]|
Home Categories. Need Help? Our Support Team is here to help. Ask Question. Form Controls. You will need to import the following namespaces. Imports System. Imports iTextSharp. Populating DataGridView. InitializeComponent ;. BindDataGridView ;. Add 1, "John Hammond" , "United States" ;. Add 2, "Mudassar Khan" , "India" ;. Add 3, "Suzanne Mathews" , "France" ;. Add 4, "Robert Schidner" , "Russia" ;. Public Sub New. End Sub. Dim dt As New DataTable. Add 1, "John Hammond" , "United States".
Add 2, "Mudassar Khan" , "India". Add 3, "Suzanne Mathews" , "France". Add 4, "Robert Schidner" , "Russia". Then a directory folder is created if it does not exists. This folder will be used to save the generated PDF file.
ColumnCount ;. HeaderText ;. Color , , ;. AddCell cell ;. AddCell cell. ToString ;. Exists folderPath. CreateDirectory folderPath ;. A2, 10f, 10f, 10f, 0f ;. GetInstance pdfDoc, stream ;. Open ;. Add pdfTable ;. Close ;. Object , e As System. Color , , If Not Directory. Exists folderPath Then. CreateDirectory folderPath.
End If. A2, GetInstance pdfDoc, stream. Add pdfTable. End Using. Related Articles. Add Comments. Thank you for the feedback. The comment is now awaiting moderation. You will be notified via email when the author replies to your comment. You can add your comment about this article using the form below.
Make sure you provide a valid email address else you won't be notified when the author replies to your comment Please note that all comments are moderated and will be deleted if they are Not relavant to the article Spam Advertising campaigns or links to other sites Abusive content.
Please do not post code, scripts or snippets. Required Invalid Email Address. Security code:. Required Invalid security code.
Export datagridview data to pdf C#
Home Categories. Need Help? Our Support Team is here to help. Ask Question. Form Controls. You will need to import the following namespaces.
Export DataGridView Data To PDF In C#
Subscribe to RSS
In this blog, we will learn how to export DataGridView data to pdf using C code. Amit Mohanty Updated date, Aug 02, In this code example, we will learn how to export DataGridView data to a pdf file and save that in a folder using C code. In this program, first, we have to get connected to the database and fetch data from the DB and show it in the Data GridView like the below image. To do that, right-click on the project and select "Manage NuGet Package" menu. After that go to the "Browse" tab and search for iTextSharp and install it.
- KASHMIR IN CONFLICT VICTORIA SCHOFIELD PDF
- HEINRICH CORNELIUS AGRIPPA VON NETTESHEIM PDF
- HOWARD RAIFFA THE ART AND SCIENCE OF NEGOTIATION PDF
- MACROCICLOS MESOCICLOS Y MICROCICLOS PDF
- DATTATREYA SAHASRANAMAM PDF
- AVENUE Q VOCAL SCORE PDF
- BUILDING THE DATA WAREHOUSE WH INMON PDF
- LITURGIA ORELOR PDF
- JAWSHAN KABEER PDF