微科社区,轻松开发从此开始! 请登陆 免费注册

微科社区

如何将adodc1控件的数据集,导出excel啊?

时间:2017-02-17 04:01  浏览:努力统计中...
如果指定字段我还会。但是现在要整个adodc1的数据集整个拷贝到excel 将数据集导入到excel Dim xlAp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet Set xlApp = CreateObject(Excel.Ap
如果指定字段我还会。但是现在要整个adodc1的数据集整个拷贝到excel
  

  '将数据集导入到excel
 Dim xlAp As Excel.Application
 Dim xlBook As Excel.Workbook
 Dim xlSheet As Excel.Worksheet
 
 Set xlApp = CreateObject("Excel.Application")
 Set xlBook = xlApp.Workbooks.Open("c:\订单报表.xlsx")
 Set xlSheet = xlBook.Worksheets(1)
 xlApp.Visible = True
 
 Dim u As Integer '定位单元格 行
 Dim v As Integer '定位单元格 列
 Dim q As Integer '数据集的数量
 Dim p As Integer '数据的字段数
   
  u = 1: v = 1
  p = 35
  q = Adodc1.Recordset.RecordCount
  Adodc1.Recordset.MoveFirst
  

For u = 1 To q
  
  For v = 1 To 35
  
   
  xlSheet.Cells(u + 1, v) = Adodc1.Recordset.Fields("u,v")这里不知道改怎么写?
   
  
   
  Next v
   
  Adodc1.Recordset.MoveNext
   
Next u

  Adodc1.Recordset.MoveFirst

VB code

  Next u
Private Sub Command1_Click() Dim xlAp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Open("c:\订单报表.xlsx") Set xlSheet = xlBook.Worksheets(1) xlApp.Visible = True Dim u As Integer '定位单元格 行 Dim v As Integer '定位单元格 列 Dim q As Integer '数据集的数量 Dim p As Integer '数据的字段数 '
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线------