在VB中怎样将ACCESS的数据导出导入到EXCEL中

本文介绍如何使用Visual Basic(VB)程序,将ACCESS数据库中的数据导出并导入到Excel文件中,涉及数据库连接、SQL查询及文件操作等技术。
摘要由CSDN通过智能技术生成

主  题:  
在VB中怎样将ACCESS的数据导出导入到EXCEL中
 
     
如题
  回复人: didishu0807(虫虫) ( ) 信誉:100 2003-08-26 11:00:46Z 得分:5
 
 
?
Dim a As Excel.Application
Set a = New Excel.Application
a.Visible = True
a.Workbooks.Add
Top
 
  回复人: lihonggen0(李洪根,MS MVP,标准答案来了) ( ) 信誉:294 2003-08-26 11:59:34Z 得分:10
 
 
?
参考:
http://www.csdn.net/develop/read_article.asp?id=14952
Top
 
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Dim extend_str As String Dim execl_cnn As New ADODB.Connection Dim execl_rst As New ADODB.Recordset Dim execl_count_rst As New ADODB.Recordset '纪录数量 Dim execl_field_rst As New ADODB.Recordset Dim execl_strconn As String Dim execl_strcmd As String Dim execl_count_str As String Dim insertStr As String 操作oracle数据库的记录集 Dim rst As ADODB.Recordset CommonDialog1.ShowOpen extend_str = Right(CommonDialog1.FileName, 3) If (extend_str = "xls") Then execl_cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & CommonDialog1.FileName & _ ";Extended Properties=Excel 8.0;" ElseIf (extend_str = "dbf") Then execl_cnn.ConnectionString = "Provider=MSDASQL.1;Driver=Microsoft Visual Foxpro Driver;SourceType=DBF;DBQ=" & getDir (CommonDialog1.FileName) execl_cnn.Open End If If (extend_str = "xls") Then execl_strcmd = "SELECT * from `Sheet1$` " execl_count_str = "SELECT count(*) from `Sheet1$` " execl_field_rst.Open execl_count_str, execl_cnn If (execl_field_rst.Fields(0).Value = 0) Then execl_strcmd = "SELECT * from [" & getFileNoExt(getfile(CommonDialog1.FileName)) & "$] " execl_count_str = "SELECT count(*) from [" & getFileNoExt(getfile(CommonDialog1.FileName)) & "$] " End If execl_field_rst.Close ElseIf (extend_str = "dbf") Then execl_strcmd = "SELECT * from " & CommonDialog1.FileName execl_count_str = "SELECT count(*) from " & CommonDialog1.FileName End If execl_rst.Open execl_strcmd, execl_cnn execl_count_rst.Open execl_count_str, execl_cnn If (CommonDialog1.FileName "") Then '进度条设置 ProgressBar1.Min = 0 ProgressBar1.max = execl_count_rst.Fields(0).Value If (execl_rst.RecordCount) Then '如果有记录 If (Option1.Value) Then '如果是仪器总库 If (execl_rst.Fields.Count = 8) Then Set rst = yg_gain_table_recordset("yg_device") execl_rst.MoveFirst Do While (Not execl_rst.EOF) rst.AddNew rst.Fields(0).Value = yg_getNextId("yg_device_id") rst.Fields(1).Value = execl_rst.Fields(0).Value & "" rst.Fields(2).Value = execl_r

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值