一个奇怪的问题,使用cell组件打印时候出现空页,附上代码,大家帮忙看下
以下是我程序中出现空表的代码,我的程序中有几个表,就这个打印时候出现空页,我觉得我写的跟其他的一样的,不知道为什么会出现错误,麻烦大家帮忙看下!谢谢了
& "markbackup.datef+markbackup.timef as selleddate,markbackup.carlength,markbackup.carwidth from markbackup " _
& "left join gkfybackup on markbackup.lsxh=gkfybackup.lsxh and markbackup.datef=gkfybackup.datef " _
& "left join carclass on carclass.cartype=substring(markbackup.cldm,2,1) " _
& "where markbackup.datef+markbackup.timef between '" & DTPStar & "' and '" & DTPEnd & "' and tpqk=0"
Set rst = cn.OpenResultset(sql, rdOpenStatic, rdConcurReadOnly)
If rst.RowCount > 46 Then
Cell1.SetRows rst.RowCount + 6, 0
End If
If Not rst.EOF Then
rst.MoveFirst
For i = 1 To rst.RowCount
Cell1.SetCellString 1, 3 + i, 0, Trim(rst!cz)
Cell1.SetCellString 2, 3 + i, 0, Trim(rst!k06)
Cell1.SetCellString 3, 3 + i, 0, Trim(rst!total_tran_wei)
Cell1.SetCellString 9, 3 + i, 0, Trim(rst!K13)
Cell1.SetCellString 10, 3 + i, 0, Trim(rst!SelledDate)
k06 = k06 + Round(IIf(IsNull(Trim(rst!k06)), 0, Trim(rst!k06)), 2)
total_tran_wei = total_tran_wei + Round(IIf(IsNull(Trim(rst!total_tran_wei)), 0, Trim(rst!total_tran_wei)), 2)
If Round(IIf(IsNull(Trim(rst!carwidth)), 0, Trim(rst!carwidth)), 2) > 3.1 And Round(IIf(IsNull(Trim(rst!carlength)), 0, Trim(rst!carlength)), 2) > 18 Then
GKF01 = GKF01 + Round(IIf(IsNull(Trim(rst!GKF01)), 0, Trim(rst!GKF01)), 2) * 2.5
GKF02 = GKF02 + Round(IIf(IsNull(Trim(rst!GKF02)), 0, Trim(rst!GKF02)), 2) * 2.5
GKF03 = GKF03 + Round(IIf(IsNull(Trim(rst!GKF03)), 0, Trim(rst!GKF03)), 2) * 2.5
GKF08 = GKF08 + Round(IIf(IsNull(Trim(rst!GKF08)), 0, Trim(rst!GKF08)), 2) * 2.5
GKF09 = GKF09 + Round(IIf(IsNull(Trim(rst!GKF09)), 0, Trim(rst!GKF09)), 2) * 2.5
Cell1.SetCellString 4, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF01)), 0, Trim(rst!GKF01)), 2) * 2.5)
Cell1.SetCellString 5, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF02)), 0, Trim(rst!GKF02)), 2) * 2.5)
Cell1.SetCellString 6, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF03)), 0, Trim(rst!GKF03)), 2) * 2.5)
Cell1.SetCellString 7, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF08)), 0, Trim(rst!GKF08)), 2) * 2.5)
Cell1.SetCellString 8, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF09)), 0, Trim(rst!GKF09)), 2) * 2.5)
Else
If Round(IIf(IsNull(Trim(rst!carwidth)), 0, Trim(rst!carwidth)), 2) > 3.1 And Round(IIf(IsNull(Trim(rst!carlength)), 0, Trim(rst!carlength)), 2) <= 18 Then
GKF01 = GKF01 + Round(IIf(IsNull(Trim(rst!GKF01)), 0, Trim(rst!GKF01)), 2) * 1.5
GKF02 = GKF02 + Round(IIf(IsNull(Trim(rst!GKF02)), 0, Trim(rst!GKF02)), 2) * 1.5
GKF03 = GKF03 + Round(IIf(IsNull(Trim(rst!GKF03)), 0, Trim(rst!GKF03)), 2) * 1.5
GKF08 = GKF08 + Round(IIf(IsNull(Trim(rst!GKF08)), 0, Trim(rst!GKF08)), 2) * 1.5
GKF09 = GKF09 + Round(IIf(IsNull(Trim(rst!GKF09)), 0, Trim(rst!GKF09)), 2) * 1.5
Cell1.SetCellString 4, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF01)), 0, Trim(rst!GKF01)), 2) * 1.5)
Cell1.SetCellString 5, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF02)), 0, Trim(rst!GKF02)), 2) * 1.5)
Cell1.SetCellString 6, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF03)), 0, Trim(rst!GKF03)), 2) * 1.5)
Cell1.SetCellString 7, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF08)), 0, Trim(rst!GKF08)), 2) * 1.5)
Cell1.SetCellString 8, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF09)), 0, Trim(rst!GKF09)), 2) * 1.5)
Else
GKF01 = GKF01 + Round(IIf(IsNull(Trim(rst!GKF01)), 0, Trim(rst!GKF01)), 2)
GKF02 = GKF02 + Round(IIf(IsNull(Trim(rst!GKF02)), 0, Trim(rst!GKF02)), 2)
GKF03 = GKF03 + Round(IIf(IsNull(Trim(rst!GKF03)), 0, Trim(rst!GKF03)), 2)
GKF08 = GKF08 + Round(IIf(IsNull(Trim(rst!GKF08)), 0, Trim(rst!GKF08)), 2)
GKF09 = GKF09 + Round(IIf(IsNull(Trim(rst!GKF09)), 0, Trim(rst!GKF09)), 2)
Cell1.SetCellString 4, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF01)), 0, Trim(rst!GKF01)), 2))
Cell1.SetCellString 5, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF02)), 0, Trim(rst!GKF02)), 2))
Cell1.SetCellString 6, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF03)), 0, Trim(rst!GKF03)), 2))
Cell1.SetCellString 7, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF08)), 0, Trim(rst!GKF08)), 2))
Cell1.SetCellString 8, 3 + i, 0, Trim(Round(IIf(IsNull(Trim(rst!GKF09)), 0, Trim(rst!GKF09)), 2))
End If
End If
K13 = K13 + Round(IIf(IsNull(Trim(rst!K13)), 0, Trim(rst!K13)), 2)
'Cell1.SetRowHeight 1, 30, 3 + i, 0
If (i Mod 2) = 0 Then
Dim n4 As Integer
For n4 = 1 To 10
Cell1.SetCellBackColor n4, 3 + i, 0, Cell1.FindColorIndex(RGB(255, 255, 200), 1)
Next
End If
rst.MoveNext
Next
Cell1.SetCellString 1, 3 + i, 0, "合计"
Cell1.SetCellString 2, 3 + i, 0, Round(k06, 2)
Cell1.SetCellString 3, 3 + i, 0, Round(total_tran_wei, 2)
Cell1.SetCellString 4, 3 + i, 0, Round(GKF01, 2)
Cell1.SetCellString 5, 3 + i, 0, Round(GKF02, 2)
Cell1.SetCellString 6, 3 + i, 0, Round(GKF03, 2)
Cell1.SetCellString 7, 3 + i, 0, Round(GKF08, 2)
Cell1.SetCellString 8, 3 + i, 0, Round(GKF09, 2)
Cell1.SetCellString 9, 3 + i, 0, Round(K13, 2)
Cell1.SetCellBackColor -1, 3 + i, 0, Cell1.FindColorIndex(RGB(209, 228, 255), 1)
Cell1.SetRowHeight 1, 30, 3 + i, 0
Cell1.SetCellFontStyle -1, 3 + i, 0, 2
cyf = Round(GKF01, 2)
zyf = Round(K13, 2)
countC = rst.RowCount
End If
Cell1.SetCellString 1, 2, 1, "从" & DTPStar & "到" & DTPEnd & ",车单数:" & countC & "张,客票数:" & countK & "张,船运费:" & cyf & "元,总运费:" & zyf & "元。"
Cell1.SetCellString 1, 2, 0, "从" & DTPStar & "到" & DTPEnd & ",车单数:" & countC & "张,客票数:" & countK & "张,船运费:" & cyf & "元,总运费:" & zyf & "元。"
Cell1.SetCurSheet 0
Cell1.MoveToCell 1, 1
rst.Close
End Sub
[解决办法]
帮顶一下,建议楼主详细说明下,没有注释别人很难看懂的。