首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

一个奇怪的有关问题,使用cell组件打印时候出现空页,附上代码,大家帮忙看下

2012-02-16 
一个奇怪的问题,使用cell组件打印时候出现空页,附上代码,大家帮忙看下以下是我程序中出现空表的代码,我的

一个奇怪的问题,使用cell组件打印时候出现空页,附上代码,大家帮忙看下
以下是我程序中出现空表的代码,我的程序中有几个表,就这个打印时候出现空页,我觉得我写的跟其他的一样的,不知道为什么会出现错误,麻烦大家帮忙看下!谢谢了
[code=VB][/code]

Private Sub Sell_mx()
Cell1.ResetContent
Cell1.SetSheetLabel 0, "车单明细"
Cell1.SetCellString 1, 1, 0, "时间段售票情况车单明细表"
Cell1.SetCellFontStyle 1, 1, 0, 2
Cell1.SetCellFontSize 1, 1, 0, 15
Cell1.SetCellAlign 1, 1, 0, 32 + 4
Cell1.SetRowHeight 1, Cell1.GetRowBestHeight(1), 1, 0
Cell1.MergeCells 1, 1, 10, 1
Cell1.SetCellString 1, 2, 0, "船名:"
Cell1.MergeCells 1, 2, 10, 2
Cell1.SetCellFontStyle -1, 2, 0, 2
Cell1.SetRowHeight 1, 30, 2, 0
Cell1.SetCellString 1, 3, 0, "车型"
Cell1.SetCellString 2, 3, 0, "单元重量"
Cell1.SetCellString 3, 3, 0, "计费吨位"
Cell1.SetCellString 4, 3, 0, "船舶运费"
Cell1.SetCellString 5, 3, 0, "港口作业费"
Cell1.SetCellString 6, 3, 0, "港务费"
Cell1.SetCellString 7, 3, 0, "海峡管理"
Cell1.SetCellString 8, 3, 0, "调节资金"
Cell1.SetCellString 9, 3, 0, "总价"
Cell1.SetCellString 10, 3, 0, "售票时间"
Cell1.SetRowHeight 1, 30, 3, 0
Cell1.SetCellBackColor -1, 3, 0, Cell1.FindColorIndex(RGB(209, 228, 255), 1)
Cell1.SetColWidth 1, 60, 1, 0
Cell1.SetColWidth 1, 90, 2, 0
Cell1.SetColWidth 1, 90, 3, 0
Cell1.SetColWidth 1, 90, 4, 0
Cell1.SetColWidth 1, 90, 5, 0
Cell1.SetColWidth 1, 80, 6, 0
Cell1.SetColWidth 1, 70, 7, 0
Cell1.SetColWidth 1, 70, 8, 0
Cell1.SetColWidth 1, 100, 9, 0
Cell1.SetColWidth 1, 160, 10, 0
Cell1.SetCellAlign 1, -1, 0, 32 + 4
Cell1.SetCellAlign 2, -1, 0, 32 + 4
Cell1.SetCellAlign 3, -1, 0, 32 + 4
Cell1.SetCellAlign 4, -1, 0, 32 + 4
Cell1.SetCellAlign 5, -1, 0, 32 + 4
Cell1.SetCellAlign 6, -1, 0, 32 + 4
Cell1.SetCellAlign 7, -1, 0, 32 + 4
Cell1.SetCellAlign 8, -1, 0, 32 + 4
Cell1.SetCellAlign 9, -1, 0, 32 + 4
Cell1.SetCellAlign 10, -1, 0, 32 + 4
Cell1.SetFixedRow 1, 3
sql = "select carclass.cz,mark.k06,mark.total_tran_wei,gkfy.gkf01,gkfy.gkf02,gkfy.gkf03,gkfy.gkf08,gkfy.gkf09,mark.k13," _
  & "mark.datef+mark.timef as selleddate,mark.carlength,mark.carwidth from mark " _
  & "left join gkfy on mark.lsxh=gkfy.lsxh and mark.datef=gkfy.datef " _
  & "left join carclass on carclass.cartype=substring(mark.cldm,2,1) " _
  & "where mark.datef+mark.timef between '" & DTPStar & "' and '" & DTPEnd & "' and tpqk=0" _
  & " Union all " _
  & "select carclass.cz,markbackup.k06,markbackup.total_tran_wei,gkfybackup.gkf01,gkfybackup.gkf02,gkfybackup.gkf03,gkfybackup.gkf08,gkfybackup.gkf09,markbackup.k13," _
  & "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


[解决办法]
帮顶一下,建议楼主详细说明下,没有注释别人很难看懂的。

热点排行