vb讀取excel數(shù)據(jù)的教程
在Excle中錄入好數(shù)據(jù)以后,可能會(huì)需要用VB進(jìn)行讀取Excle數(shù)據(jù),具體該如何讀取數(shù)據(jù)呢?下面是學(xué)習(xí)啦小編帶來的關(guān)于vb讀取excel數(shù)據(jù)的教程,希望閱讀過后對(duì)你有所啟發(fā)!
vb讀取excel數(shù)據(jù)的教程:
Private Sub Form_Load()
Text1.Text = App.Path & "3.xls"
Text2.Text = App.Path & "3.mdb"
Text3.Text = "sheet1"
Text4.Text = "sheet1"
Data1.DatabaseName = App.Path & "3.mdb"
End Sub
Private Sub Command1_Click()
Dim db As Database
Dim sheet As String, excelpath As String, AccessPath As String, AccessTable As String
AccessPath = Text2.Text '數(shù)據(jù)庫(kù)路徑
excelpath = Text1.Text '電子表格路經(jīng)
AccessTable = Text4.Text '數(shù)據(jù)庫(kù)內(nèi)表格
sheet = Text3.Text '電子表格內(nèi)工作表
Set db = OpenDatabase(excelpath, True, False, "Excel 5.0") '打開電子表格文件
SQL = ("Select * into [;database=" & AccessPath & "]." & AccessTable & " FROM [" & sheet & "$]")
db.Execute (SQL) '將電子表格導(dǎo)入數(shù)據(jù)庫(kù)
Data1.RecordSource = "sheet1"
Data1.Refresh
DBGrid1.Refresh '顯示電子表格導(dǎo)入到數(shù)據(jù)庫(kù)的數(shù)據(jù)
End Sub
上面的是把EXCEL讀取到數(shù)據(jù)庫(kù)中,你做點(diǎn)修改就行了.一個(gè)Data控件.
看了vb讀取excel數(shù)據(jù)的教程還看了:
1.如何利用excel進(jìn)行數(shù)據(jù)分析的教程
2.如何用excel進(jìn)行數(shù)據(jù)分析的教程
3.如何用excel統(tǒng)計(jì)文本數(shù)據(jù)的教程
4.如何快速提取出Excel2010括號(hào)內(nèi)的數(shù)據(jù)信息
5.數(shù)據(jù)怎么導(dǎo)入excel的教程