|
On Error GoTo Err_导出并统计_Click
' Dim qdf As DAO.QueryDef 'qdf被定义为一个查询定义对象
' Set qdf = CurrentDb.QueryDefs("导出结果")
' qdf.SQL = str2
' qdf.Close
' Set qdf = Nothing
' DoCmd.OutputTo acOutputQuery, "导出结果", acFormatXLS, , True
Dim xlApp As Excel.Application 'Excel应用程序对象
Dim xlBook As Excel.Workbook 'Excel工作簿对象
Dim xlSheet As Excel.Worksheet 'Excel工作表对象
Dim dbs As Database, strSQL As String, X As Integer
Dim qdf As QueryDef
Dim TableA As Variant, wks As Workspace
Set wks = Workspaces(0)
'CurrentDb 方法返回一个类型为 Database 的对象变量,该变量代表了当前在
'Microsoft Access 窗口中打开的数据库。
Set dbs = CurrentDb()
Dim strpath As String
strpath = CurrentProject.Path
strpath = strpath & "\导出结果.xlt"
Set xlApp = CreateObject("Excel.Application") '创建Excel应用程序对象
Set xlApp = New Excel.Application
xlApp.Visible = True '对象的可见性为“真”
'Set xlBook = xlApp.Workbooks.Open("D:\餐饮业管理\导出结果.xlt")
Set xlBook = xlApp.Workbooks.Open(strpath)
'打开“Temp.xls”文件
Set xlSheet = xlBook.Worksheets(1) '选择Sheet(1)
Set xlSheet = xlBook.ActiveSheet
'strSQL = "SELECT * FROM 厦门市餐饮调查表;"
strSQL = str2
CurrentDb.QueryDefs.Refresh '刷新当前数据库中的查询对象
For Each qdf In CurrentDb.QueryDefs '遍历查询,如果存在“导出结果
If qdf.Name = "导出结果" Then '数据”查询则删除
CurrentDb.QueryDefs.Delete qdf.Name
Exit For
End If
Next qdf
Set qdf = dbs.CreateQueryDef("导出结果", strSQL)
Set TableA = dbs.OpenRecordset("导出结果", dbOpenSnapshot) '打开查询
'导到EXCEL
xlSheet.Cells(1, 1) = "编号"
xlSheet.Cells(1, 2) = "辖区"
xlSheet.Cells(1, 3) = "填报单位"
xlSheet.Cells(1, 4) = "填报日期"
xlSheet.Cells(1, 5) = "法人代表"
xlSheet.Cells(1, 6) = "单位地址"
xlSheet.Cells(1, 7) = "联系人"
xlSheet.Cells(1, 8) = "联系电话"
xlSheet.Cells(1, 9) = "邮编"
xlSheet.Cells(1, 10) = "经度"
xlSheet.Cells(1, 11) = "纬度"
xlSheet.Cells(1, 12) = "总投资(万元)"
xlSheet.Cells(1, 13) = "营业额(万元)"
xlSheet.Cells(1, 14) = "营业面积"
xlSheet.Cells(1, 15) = "营业时间"
xlSheet.Cells(1, 16) = "环评审批"
xlSheet.Cells(1, 17) = "与周边住宅楼的距离"
xlSheet.Cells(1, 18) = "否位于住宅内"
xlSheet.Cells(1, 19) = "是否与居住层相临"
xlSheet.Cells(1, 20) = "环保验收"
xlSheet.Cells(1, 21) = "用水量"
xlSheet.Cells(1, 22) = "燃油量"
xlSheet.Cells(1, 23) = "规范化隔油池"
xlSheet.Cells(1, 24) = "是否燃用煤炭"
xlSheet.Cells(1, 25) = "排油烟专用烟道"
xlSheet.Cells(1, 26) = "排油烟净化设备"
xlSheet.Cells(1, 27) = "是否到达屋面"
xlSheet.Cells(1, 28) = "是否对外营业"
xlSheet.Cells(1, 29) = "餐厨垃圾产生量"
xlSheet.Cells(1, 30) = "微生物处理"
xlSheet.Cells(1, 31) = "出售或请他人清运"
xlSheet.Cells(1, 32) = "混入生活垃圾"
xlSheet.Cells(1, 33) = "倒入下水道"
xlSheet.Cells(1, 34) = "废弃食用油脂产生量"
xlSheet.Cells(1, 35) = "是否建立去向台账本"
xlSheet.Cells(1, 36) = "废弃食用油脂接收单位"
xlSheet.Cells(1, 37) = "是否有环保投诉"
xlSheet.Cells(1, 38) = "是否有环保投诉详细措施"
xlSheet.Cells(1, 39) = "备注"
xlSheet.Cells(1, 40) = "填表人"
xlSheet.Cells(1, 41) = "环保审核"
Dim i As Integer
Dim da As Double
Dim db As Double
Dim dc As Double
Dim ic As Integer
Dim id As Integer
Dim e As Integer
Dim f A |
|