Exporting data of Datagrids to Excel in VB.NET
-
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
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 worksheetdim xlWRK as Excel.Worksheet
3.define an Excel workbookdim xlWBK as Excel.Workbook
4.Open a workbook in the instantiated application:xlWBK=xlapp.workbooks.open("YourFile")
5.Get the sheet on the workbookxlWRK=xlwbk.worksheets(0)
6.Get the value on the worksheetdim 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
-
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 worksheetdim xlWRK as Excel.Worksheet
3.define an Excel workbookdim xlWBK as Excel.Workbook
4.Open a workbook in the instantiated application:xlWBK=xlapp.workbooks.open("YourFile")
5.Get the sheet on the workbookxlWRK=xlwbk.worksheets(0)
6.Get the value on the worksheetdim 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