Comment on Tutorial - How to export from database to excel using By Issac

Comment Added by : John McCode

Comment Added at : 2013-05-24 07:57:31

Comment on Tutorial : How to export from database to excel using By Issac
you do the same as after
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cnn As SqlConnection
Dim sql As String
Dim i, j As Integer

Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value

xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
cnn = Connection.getConnection()
sql = "SELECT * FROM tblNVcanhan"
Dim dscmd As New SqlDataAdapter(sql, cnn)
Dim ds As New DataSet
For i = 0 To ds.Tables(0).Columns.Count - 1
xlWorkSheet.Cells(1, i + 1) = ds.Tables(0).Columns(i).ToString()
For j = 0 To ds.Tables(0).Rows.Count - 1
xlWorkSheet.Cells(j + 2, 1) = ds.Tables(0).Columns(j).ToString()
For i = 0 To ds.Tables(0).Columns.Count - 1
xlWorkSheet.Cells(j + 2, i + 1) = ds.Tables(0).Rows(j).Item(i).ToString()
MsgBox("You can find the file D:\vbexcel.xlsx")
xlApp.Visible = True



End Sub
Private Sub releaseObject(ByVal obj As Object)
obj = Nothing
Catch ex As Exception
obj = Nothing
End Try
End Sub

View Tutorial

Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. i have created a UI in swing now i want to read th
View Tutorial          By: Ashish Gaurkhede at 2014-09-08 08:21:04

2. this is the best example of method overriding but
View Tutorial          By: Dipesh at 2009-09-09 12:52:21

3. 510

View Tutorial          By: sky at 2010-07-17 06:54:46

4. pritnt
1 2 3 4 5

View Tutorial          By: osama at 2013-02-05 03:16:15

5. informative article.......
View Tutorial          By: Nithin at 2012-08-17 15:32:37

6. hello sir , i just implement your code and modify
View Tutorial          By: tushar at 2012-01-31 05:21:37

7. Enough to understand basic concept.Thanks.
View Tutorial          By: Jyothylakshmy P u at 2012-09-18 05:35:48

8. Very useful tutorial. But if same code is executed
View Tutorial          By: Jitendra Kumar Mahto at 2011-08-12 15:10:14

9. Great details you provided here, very straight for
View Tutorial          By: Jackie Wong at 2010-02-05 10:52:25

10. Very helpful and easily understandable!
View Tutorial          By: Teerna at 2014-11-12 23:55:49