We always search for the best way to export Access data to Excel for working more efficiently. It is no doubt that there are materials about this problem. And some people are very familiar with the method. However, we need to check if the method is suitable for the practical situation. Also, we will have many troubles when operating according to different requirements.
Microsoft Access and Excel are considered as the basic tools during the process of exporting. However, some developers may not install the two tools. At that time, how do they realize export data to Excel? Now, I want to introduce a way to export Access data to Excel with VB.Net if we don’t have Microsoft.
The following code shows us the detailed process
Private Sub btnMSAccess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMSAccess.Click
Dim oleDbConnection1 As New System.Data.OleDb.OleDbConnection()
oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\..\..\Database\demo.mdb
Dim oleDbCommand1 As New System.Data.OleDb.OleDbCommand()
oleDbCommand1.CommandText = "select * from parts"
oleDbCommand1.Connection = oleDbConnection1
Dim accessExport1 As New Spire.DataExport.Access.AccessExport()
accessExport1.DatabaseName = "test.mdb"
accessExport1.DataFormats.CultureName = "zh-CN"
accessExport1.DataFormats.Currency = "c"
accessExport1.DataFormats.DateTime = "yyyy-M-d H:mm"
accessExport1.DataFormats.Float = "g"
accessExport1.DataFormats.[Integer] = "g"
accessExport1.DataFormats.Time = "H:mm"
accessExport1.SQLCommand = oleDbCommand1
accessExport1.TableName = "ExportData"
oleDbConnection1.Open()
accessExport1.SaveToFile()
End Sub
This method can export data in Access to Excel quickly. And this method can deal with a large amount of data. What’s more, if we want to export data to many different Excel Workbooks, this method is very useful for it can complete it with a short time.
Of course, we also can find several kinds of good add-in which specialize in exporting data. As I know, Spire.DataExport is very helpful. It not just exports data in database to Excel, but another file format, such as Word, PDF and so on. Recently, it published a free component version which offers customers to experience if it is suitable for their requirements.
To sum up, we should evaluate the methods for exporting Access data to Excel before we choose.
Post je objavljen 24.01.2011. u 10:54 sati.