我想把excel表格的内容导入到access数据库中,然后在VB的控制里显示出来,不知道该怎么做。请大家帮帮忙
解决方案 »
- 用控件数组实现单选框和复选框
- 怎么样在unload事件里取消 Unload
- vb可以作采集系统吗?
- 如何让水晶报表每页固定行数,不足行数的补充空行?
- 简单打印问题?
- 请问怎么样用enter键来控制焦点的移动?
- 有没有打印EXECL的打印控件啊????
- 怎样才能把VB鼠标取词的那个程序应用到网页上呢?
- 请问哪位大哥有cell32.ocx报表控件的id和password,小弟急需,非常感谢!
- 问: 怎么得到系统的所有字体 ?--------------------------------------------------
- 类型转换问题
- 请问为何我的打印结果总是偏位呀?打印出的票据不在指定的位置上。(请高手赐教我第一次写打印程序)
我直接处理粘贴板的数据 、
这样可以避免兼容性问题
http://topic.csdn.net/u/20080828/09/44109f8f-666b-4fa1-88be-e784c66eddf1.html
Dim excel_app As Object
Dim excel_sheet As Object
Dim db As Database
Dim AccessPath As String, AccessTable As String
Dim sql As String
Dim frm As New frmMessage
Dim msg As String
ADOsdb.BeginTrans
' With ADOsdb
' If .State <> adStateOpen Then
' .CursorLocation = adUseClient
' .ConnectionString = gsOdbcName
' .Open
' End If
' End With
With dlgCommonDialog
.DialogTitle = "打开"
.CancelError = False
'ToDo: 设置 common dialog 控件的标志和属性
.Filter = "Excel文件 (*.xls) ¦*.xls"
.ShowOpen
If Len(.FileName) = 0 Then
Exit Sub
End If
sfile = .FileName
End With
AccessPath = lcspath & "\db.mdb" '数据库路径
excelpath = sfile '电子表格路经
AccessTable = "db" '数据库内表格
msg = Trim(InputBox("请输入表名,如sheet1或sheet2:", "工作表", "sheet1"))
' msg = Str(msg)
sheet = msg '电子表格内工作表
Set db = OpenDatabase(excelpath, True, False, "Excel 8.0") '打开电子表格文件
sql = ("Select * into [;database=" & AccessPath & "]." & AccessTable & " FROM [" & sheet & "$]")
' sql = ("Select * into [;database=" & AccessPath & "]." & AccessTable & " FROM [" & sheet & "]")
If sheet = "" Then
MsgBox "您选择的EXCEL表不存在,请重新导入!", vbInformation, "抱歉!"
Exit Sub
End If
If deltable = 1 Then
With ADOsdb
.Execute "drop table db", , adCmdText
End With
End If
ADOsdb.CommitTrans db.Execute (sql) '将电子表格导入数据库
ShowMessage "正在导入EXCEL表,请您稍等..."
Timer1.Enabled = True