vb读取excel数据的教程:
Private Sub Form_Load()
Text1.Text = App.Path &"\123.xls"
Text2.Text = App.Path &"\123.mdb"
Text3.Text = "sheet1"
Text4.Text = "sheet1"
Data1.DatabaseName = App.Path &"\123.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 '数据库路径
excelpath = Text1.Text '电子表格路经
AccessTable = Text4.Text '数据库内表格
sheet = Text3.Text '电子表格内工作表
Set db = OpenDatabase(excelpath, True, False, " Excel 5.0") '打开电子表格文件
SQL = ("Select * into [database=" &AccessPath &"]." &AccessTable &" FROM [" &sheet &"$]")
db.Execute (SQL) '将电子表格导入数据库
Data1.RecordSource = "sheet1"
Data1.Refresh
DBGrid1.Refresh '显示电子表格导入到数据库的数据
End Sub
上面的是把EXCEL读取到数据库中,你做点修改就行了.一个Data控件.
分类: 电脑/网络 >>程序设计 >>其他编程语言问题描述:
最好详细点,兄弟笨笨的呢
解析:
Private Sub Form_Load()
Text1.Text = App.Path &"\123.xls"
Text2.Text = App.Path &"\123.mdb"
Text3.Text = "sheet1"
Text4.Text = "sheet1"
Data1.DatabaseName = App.Path &"\123.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 '数据库路径
excelpath = Text1.Text '电子表格路经
AccessTable = Text4.Text '数据库内表格
sheet = Text3.Text '电子表格内工作表
Set db = OpenDatabase(excelpath, True, False, "Excel 5.0") '打开电子表格文件
SQL = ("Select * into [database=" &AccessPath &"]." &AccessTable &" FROM [" &sheet &"$]")
db.Execute (SQL) '将电子表格导入数据库
Data1.RecordSource = "sheet1"
Data1.Refresh
DBGrid1.Refresh '显示电子表格导入到数据库的数据
End Sub
上面的是把EXCEL读取到数据库中,你做点修改就行了.一个Data控件.
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)