Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Exporting data of Datagrids to Excel in VB.NET

Exporting data of Datagrids to Excel in VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharphelplearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hsprasain
    wrote on last edited by
    #1

    Hi I have a DataGrid on a Windows form and want to export the data of Datagrids to an Excel worksheet. I'm beginner to VB.NET programming. I'd appreciate if somebody can help me. hprasain

    T 1 Reply Last reply
    0
    • H hsprasain

      Hi I have a DataGrid on a Windows form and want to export the data of Datagrids to an Excel worksheet. I'm beginner to VB.NET programming. I'd appreciate if somebody can help me. hprasain

      T Offline
      T Offline
      Taylor
      wrote on last edited by
      #2

      0.Add Excel Object Library 11 Refrence to your project which is a COM 1. Instatiate an Excel application: dim xlApp as new Excel.Application 2.define an Excel worksheet dim xlWRK as Excel.Worksheet 3.define an Excel workbook dim xlWBK as Excel.Workbook 4.Open a workbook in the instantiated application: xlWBK=xlapp.workbooks.open("YourFile") 5.Get the sheet on the workbook xlWRK=xlwbk.worksheets(0) 6.Get the value on the worksheet dim value as string = xlwrk.cells(1,1).value() **Note:**Indexes of cells wil begin from 1 **Note:**Call xlapp.quit when you do not need the application(it may remain in the memory) **Note:**You can view the excel application by changing the visible property of xlapp to true(xlapp.visible=true)

      A.E.K

      H 1 Reply Last reply
      0
      • T Taylor

        0.Add Excel Object Library 11 Refrence to your project which is a COM 1. Instatiate an Excel application: dim xlApp as new Excel.Application 2.define an Excel worksheet dim xlWRK as Excel.Worksheet 3.define an Excel workbook dim xlWBK as Excel.Workbook 4.Open a workbook in the instantiated application: xlWBK=xlapp.workbooks.open("YourFile") 5.Get the sheet on the workbook xlWRK=xlwbk.worksheets(0) 6.Get the value on the worksheet dim value as string = xlwrk.cells(1,1).value() **Note:**Indexes of cells wil begin from 1 **Note:**Call xlapp.quit when you do not need the application(it may remain in the memory) **Note:**You can view the excel application by changing the visible property of xlapp to true(xlapp.visible=true)

        A.E.K

        H Offline
        H Offline
        hsprasain
        wrote on last edited by
        #3

        Thanks a lot! To make your code work well I have to make a change on xlWRK=xlwbk.worksheets(0) to xlWRK=xlwbk.worksheets(1). Once more thanks a lot!!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups