VB程序导出数据到Excel.docx
《VB程序导出数据到Excel.docx》由会员分享,可在线阅读,更多相关《VB程序导出数据到Excel.docx(3页珍藏版)》请在三一办公上搜索。
1、VB程序导出数据到Excelvb导出数据到Excel Public Function ExporToExcel(strOpen As String,cn As ADODB.Connection) 入参为SQL查询语句,cn为当前活动的连接 * * 名称:ExporToExcel * 功能:导出数据到EXCEL * 用法:ExporToExcel(sql查询字符串) * Dim Rs_Data As New ADODB.Recordset Dim Irowcount As Integer Dim Icolcount As Integer Dim FILENAME As String Dim xl
2、App As New Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet Dim xlQuery As Excel.QueryTable With Rs_Data If .State = adStateOpen Then .Close End If .ActiveConnection = Cn .CursorLocation = adUseClient .CursorType = adOpenStatic .LockType = adLockReadOnly .Source = strOpe
3、n .Open End With With Rs_Data If .RecordCount 1 Then MsgBox (没有记录!) Exit Function End If 记录总数 Irowcount = .RecordCount 字段总数 Icolcount = .Fields.Count End With Set xlApp = CreateObject(Excel.Application) Set xlBook = Nothing Set xlSheet = Nothing Set xlBook = xlApp.Workbooks.Add Set xlSheet = xlBook.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VB 程序 导出 数据 Excel
链接地址:https://www.31ppt.com/p-3168288.html