Önce Forma bir adet GridControl ekle sonra forma tıkla ve aşağıdaki gibi olsun
Imports System.Data.SqlClient
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim Reader As StreamReader = File.OpenText("sql.txt")
Dim FileText As String = Reader.ReadToEnd()
Reader.Close()
MemoEdit1.Text = FileText
Dim connectionString As String = "Data Source=KLCTRCK;Initial Catalog=LKSDB;User ID=semsem;Password=xaaxpass"
Dim sql As String = MemoEdit1.Text
Dim connection As New SqlConnection(connectionString)
Dim dataadapter As New SqlDataAdapter(sql, connection)
Dim ds As New DataSet()
connection.Open()
dataadapter.Fill(ds, "Firma")
connection.Close()
GridControl1.DataSource = ds
GridControl1.DataMember = "Firma"
GridView1.OptionsView.ColumnAutoWidth = False 'Gridviewei otomatik genişlik ayarı
GridView1.OptionsView.BestFitMaxRowCount = -1
GridView1.BestFitColumns()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'xls olarak kaydet
SaveFileDialog1.Filter = "XLS Files (*.xls*)|*.xls"
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK _
Then
GridControl1.ExportToXls(SaveFileDialog1.FileName)
End If
End Sub
End Class
Imports System.Data.SqlClient
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim Reader As StreamReader = File.OpenText("sql.txt")
Dim FileText As String = Reader.ReadToEnd()
Reader.Close()
MemoEdit1.Text = FileText
Dim connectionString As String = "Data Source=KLCTRCK;Initial Catalog=LKSDB;User ID=semsem;Password=xaaxpass"
Dim sql As String = MemoEdit1.Text
Dim connection As New SqlConnection(connectionString)
Dim dataadapter As New SqlDataAdapter(sql, connection)
Dim ds As New DataSet()
connection.Open()
dataadapter.Fill(ds, "Firma")
connection.Close()
GridControl1.DataSource = ds
GridControl1.DataMember = "Firma"
GridView1.OptionsView.ColumnAutoWidth = False 'Gridviewei otomatik genişlik ayarı
GridView1.OptionsView.BestFitMaxRowCount = -1
GridView1.BestFitColumns()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'xls olarak kaydet
SaveFileDialog1.Filter = "XLS Files (*.xls*)|*.xls"
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK _
Then
GridControl1.ExportToXls(SaveFileDialog1.FileName)
End If
End Sub
End Class