My application is in VS2008 and coded in Vb.net.
I have my database in Sql Server 2005.I have a Database table say Table1 in My Database named Test.
Now i want to export the data in Table1 to a MS-Excel(.xls) file on the click of a button.
An excel file should be generated after the user clicks on the button and the generated Excel file should have the data that is present in Table1.
Can anyone provide me with a link or some helpful code to do this.
My code is in Vb.net
Jump to Post
If ((DataGridView1.Columns.Count = 0) Or (DataGridView1.Rows.Count = 0)) Then Exit Sub End If 'Creating dataset to export Dim dset As New DataSet 'add table to dataset dset.Tables.Add() 'add column to that table For i As Integer = 0 To DataGridView1.ColumnCount - 1 dset.Tables(0).Columns.Add(DataGridView1.Columns(i).HeaderText) Next 'add rows to …
All 9 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.