|
首先要判断EXCEL表中的SHEET最大行号
定位第一条记录, 用记录集循环写进,保存退出
Set appExcel = Excel.Application
Set wbk = appExcel.Workbooks.Open(CurrentProject.Path & "\ExcelFile\" & StrFileName)
Set wks = appExcel.Worksheets("Sheet1")
Y = 5
Sql = "SELECT * FROM LCDHealthQuery ORDER BY Technology"
Rs.Open Sql, Conn, adOpenKeyset, adLockOptimistic
K = Rs.Fields.Count + 2
For J = 1 To Rs.Fields.Count - 1
wks.Cells(Y, J + 2).Value = Rs.Fields(J).Name
Next
For J = 1 To Rs.Fields.Count - 1
If Left(Rs.Fields(J).Name, 2) = "WK" Then
If Rsc.Fields(J).Name >= Me.CmdStarWeek Then
StrYear = Me.CmbStarYear
Else
StrYear = Me.CmbStarYear + 1
End If
wks.Cells(Y + 1, J + 2).Value = DLookup("WeekStar", "", "PlanYear='" & StrYear & "' and WeekName='" & Rsc.Fields(J).Name & "'")
Else
wks.Cells(Y + 1, J + 2).Value = Rs.Fields(J).Name
End If
Next
Rs.MoveFirst
Y = 7
.....后面自已写 |
|