|
VB中使用EXCEL输出(8) rst_qm.Close Set rst_gcl = Nothing Set rst_qm = Nothing con.Close Set con = Nothing End If Set xlsheet = Nothing End Sub Option Explicit Public Sub ToExcelTsf(ByRef xlbook, ByRef xls) Dim con As New ADODB.Connection Dim rst_tsf As New ADODB.Recordset Dim rst_qm As New ADODB.Recordset '**********************************连接数据库************************ con.CursorLocation = adUseClient con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strConnection & ";Persist Security Info=False" con.Open rst_tsf.Open "tdefeiyong", con, adOpenKeyset, adLockOptimistic, adCmdTable If Not (rst_tsf.BOF And rst_tsf.EOF) Then rst_tsf.MoveFirst End If rst_qm.Open "qianming", con, adOpenKeyset, adLockOptimistic, adCmdTable rst_qm.MoveFirst '*********************************工作表初使化********************************** Dim xlsheet As excel.Worksheet Set xlsheet = xlbook.Sheets.Add xlsheet.Name = "机械台时、组时费汇总表" xlsheet.Columns(1).ColumnWidth = 5 xlsheet.Columns(2).ColumnWidth = 20 xlsheet.Columns(3).ColumnWidth = 7 xlsheet.Columns(4).ColumnWidth = 7 xlsheet.Columns(5).ColumnWidth = 7 xlsheet.Columns(6).ColumnWidth = 7 xlsheet.Columns(7).ColumnWidth = 7
|