VB6 adodc 导出excel的问题(可否指定字段导出) 如题,数据库中有些字段我不想导出到excel中,用select 字段,这样屏蔽的话,程序里面又有很多字段要用到,所以问下指定字段怎么处理,度娘没告诉我,求教下大家,谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ’经实际测试,以下代码数据库和Excel之间互相导入导出,完全成功!Private Sub Command1_Click() 'access导出到excel Dim db As New ADODB.Connection Dim sPath As String db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Temp\Test\db1.mdb Persist Security Info=False" sPath = App.Path + "\backup.xls" If Dir(sPath) <> "" Then Kill sPath Else Call db.Execute("select * into Sheet1 In '" & sPath & "' 'excel 8.0;' from 表1") MsgBox "导出成功", vbOKOnly, "提示" End If db.Close Set db = NothingEnd SubPrivate Sub Command2_Click() '从excel导出到 access Dim db As New ADODB.Connection Dim sPath As String db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Temp\Test\db1.mdb;Persist Security Info=False" sPath = App.Path + "\backup.xls" Call db.Execute("select * into Table4 From [Sheet1$] In '" & sPath & "' 'excel 8.0;'") db.Close Set db = NothingEnd Sub 谢谢1楼,提示in 附近有语法错误,已经在路径新建了excel文件 我又重新测试了一下,没有问题啊Private Sub Command1_Click() 'access导出到excel Dim db As New ADODB.Connection Dim sPath As String db.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\测试数据\db1.mdb; Persist Security Info=False" sPath = App.Path + "\backup.xls" If Dir(sPath) <> "" Then Kill sPath Else Call db.Execute("select * into Sheet1 In '" & sPath & "' 'excel 8.0;' from 表1") MsgBox "导出成功", vbOKOnly, "提示" End If db.Close Set db = NothingEnd SubPrivate Sub Command2_Click() '从excel导出到access Dim db As New ADODB.Connection Dim sPath As String sPath = App.Path + "\测试数据\" db.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath & "\db1.mdb;Persist Security Info=False" Call db.Execute("select * into Table4 From [Sheet1$] In '" & sPath & "\Book2.xls' 'excel 8.0;'") db.Close Set db = NothingEnd Sub 求助,真切求助,vb打开多个文件的问题 现金求VB或C程序员写个小程序 flexgrid中的打印控件如何加入图像 修改数据库DBO密码后程序无法连接数据库 如何修改操作系统的时间? vb小问题一个!!请大家帮忙 第一次来请多关照! DATAREPORT的列宽? ====用filesystemobject改动一个xml文件后,出现了这么多文字,谁能解释解释? 如何在制作安装时将各种图形与应用程序一起发行? vb+access的数据库保存新录入的员工信息提示日期时间语法错误 关于WEBBrowser控件
Private Sub Command1_Click()
'access导出到excel
Dim db As New ADODB.Connection
Dim sPath As String
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Temp\Test\db1.mdb Persist Security Info=False"
sPath = App.Path + "\backup.xls"
If Dir(sPath) <> "" Then
Kill sPath
Else
Call db.Execute("select * into Sheet1 In '" & sPath & "' 'excel 8.0;' from 表1")
MsgBox "导出成功", vbOKOnly, "提示"
End If
db.Close
Set db = Nothing
End SubPrivate Sub Command2_Click()
'从excel导出到 access
Dim db As New ADODB.Connection
Dim sPath As String
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Temp\Test\db1.mdb;Persist Security Info=False"
sPath = App.Path + "\backup.xls"
Call db.Execute("select * into Table4 From [Sheet1$] In '" & sPath & "' 'excel 8.0;'")
db.Close
Set db = Nothing
End Sub
'access导出到excel
Dim db As New ADODB.Connection
Dim sPath As String
db.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\测试数据\db1.mdb; Persist Security Info=False"
sPath = App.Path + "\backup.xls"
If Dir(sPath) <> "" Then
Kill sPath
Else
Call db.Execute("select * into Sheet1 In '" & sPath & "' 'excel 8.0;' from 表1")
MsgBox "导出成功", vbOKOnly, "提示"
End If
db.Close
Set db = Nothing
End SubPrivate Sub Command2_Click()
'从excel导出到access
Dim db As New ADODB.Connection
Dim sPath As String
sPath = App.Path + "\测试数据\"
db.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sPath & "\db1.mdb;Persist Security Info=False"
Call db.Execute("select * into Table4 From [Sheet1$] In '" & sPath & "\Book2.xls' 'excel 8.0;'")
db.Close
Set db = Nothing
End Sub