请高手帮忙看看脚本1、2 加上下面这些为一套脚本
If(a=0) Then
objExcelApp.Worksheets(sheetname).cells(i,2).value= GetLocalDate(oRs1.Fields(1).Value)
objExcelApp.Worksheets(sheetname).cells(i,4).value= oRs1.Fields(2).Value
objExcelApp.Worksheets(sheetname).cells(i,5).value= GetLocalDate(oRs1.Fields(3).Value)
objExcelApp.Worksheets(sheetname).cells(i,7).value= oRs1.Fields(4).Value
a=oRs1.Fields(2).Value
Select Case oRs2.Fields(2).Value
Case 1
objExcelApp.Worksheets(sheetname).cells(i,3).value= "DN15"
Case 101
objExcelApp.Worksheets(sheetname).cells(i,6).value= "DN50"
Case 201
objExcelApp.Worksheets(sheetname).cells(i,9).value= "DN80"
oRs1.MoveNext
oRs2.MoveNext
i=i+1
Else
objExcelApp.Worksheets(sheetname).cells(i-1,2).value= GetLocalDate(oRs1.Fields(1).Value)
objExcelApp.Worksheets(sheetname).cells(i-1,4).value= oRs1.Fields(2).Value
a=oRs1.Fields(2).Value
oRs1.MoveNext
oRs2.MoveNext
End If
End If
Loop
oRs1.Close
oRs2.Close
Else
End If
Set oRs1 = Nothing
Set oRs2 = Nothing
conn.Close
Set conn = Nothing
Dim patch,filename
filename=CStr(Year(Now))&"-"&CStr(Month(Now))&"-"&CStr(Day(Now))&" "&CStr(Hour(Now))&"."&CStr(Minute(Now))&"."&CStr(Second(Now))
patch= "d:\baobiao\chongzheng\"&filename&".xlsx"
objExcelApp.ActiveWorkbook.SaveAs patch
objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp= Nothing
图片说明:
最佳答案
Select Case oRs2.Fields(2).Value ,你的 oRs2那里来的?在这行下面用msgbox显示 oRs2.Fields(2).Value看看具体多少?如果没有数值,当然也就不能写入数据了。
提问者对于答案的评价:
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc163304.html