VB export Gridview to PDF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dan Effets
    New Member
    • Oct 2011
    • 17

    VB export Gridview to PDF

    I looking for a example of VB export gridview to PDF , all that I can find use C# or VB.net to a web page. Using ItextSharp or PDFSharp. Looking for VB only not web or ASPX .. Please send a link..thank you
  • Dan Effets
    New Member
    • Oct 2011
    • 17

    #2
    Code:
     Dim doc As New Document(iTextSharp.text.PageSize.A4, 10.0F, 10.0F, 10.0F, 10.0F)
            Dim PdfPTable As PdfPTable = New PdfPTable(DataGridView1.Columns.Count)
    
            If (j < DataGridView1.Columns.Count) Then j = +1
            PdfPTable.AddCell(DataGridView1.Columns(j).HeaderText)
    
    
            If (i < DataGridView1.Rows.Count) Then i = +1
            If (k < DataGridView1.Columns.Count) Then k = +1
            [B]If DataGridView1(k, i).Value != null Then[/B]            PdfPTable.AddCell(DataGridView1(k, i).Value.ToString())
                doc.Add(PdfPTable)
                doc.Close()
    Trying to convert from C# to VB , stuck on this line

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      I use this tool to convert between C# and VB.NET: Convert C# to VB.NET.

      It doesn't always get things 100% and I think it has some issues regarding lambda expressions but it usually gets me to a point where I can figure it out.

      Which line are you stuck on?

      I thought you were attempting to accomplish this using VB classic code?

      -Frinny

      Comment

      • Dan Effets
        New Member
        • Oct 2011
        • 17

        #4
        Code:
        If DataGridView1(k, i).Value != null Then            PdfPTable.AddCell(DataGridView1(k, i).Value.ToString())
        I am trying to convert C# example, but not having much luck
        != null cant be used in VB or Null , The orginal statement
        was For not if

        Yes classic code, but cant find examples...

        Comment

        Working...