以下代码是一个打印表格的代码,一套房子打一张表,黄色部分希望实现该表的行数如果超过20行就强制换行,怎么修改?
Dim dt1 As Table=Tables("楼面规划_table1")
Dim dt2 As DataTable=DataTables("楼面台账账面")
Dim doc As New PrintDoc '定义一个报表
Dim rt As New prt.RenderTable() '定义一个表格对象
Dim rs As New prt.RenderText() '定义一个文本对象
For i As Integer = dt1.TopRow To dt1.BottomRow
'Dim doc As New PrintDoc '定义一个报表
'Dim rm As prt.RenderEmpty
rt = New prt.RenderTable() '定义一个表格对象
rs = New prt.RenderText() '定义一个文本对象
rs.Text = DataTables("基本情况").find("项目= '单位名称'")("内容") & "楼面情况" '设置文本对象的内容
rs.Style.Font = New Font("黑体", 16 , FontStyle.Bold) '设置文本对象的字体
rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本内容水平居中
rs.Style.Spacing.Bottom = 2
Doc.PageSetting.LeftMargin = 20 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 20 '设置上边距
Doc.PageSetting.BottomMargin = 20 '设置下边距
rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中
doc.Body.Children.Add(rs) '将文本对象加入到表格中
doc.Body.Children.Add(rt) '将表格对象加入到报表中
rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
'For d As Integer = 0 To 3
'rt.cells(0,d).Style.GridLines.top = New prt.LineDef(0,Color.Green)
'rt.cells(0,d).Style.GridLines.left = New prt.LineDef(0,Color.Green)
'rt.cells(0,d).Style.GridLines.right = New prt.LineDef(0,Color.Green)
'Next
'For f As Integer = 0 To 20
'rt.cells(f,11).Style.GridLines.top = New prt.LineDef(0,Color.Green)
'rt.cells(f,11).Style.GridLines.bottom = New prt.LineDef(0,Color.Green)
'
'Next
rt.Width = 248 '表宽为150毫米
rt.Height = 170 '表高为150毫米
'rt.Cols(4).Width = 20
'rt.Cols(11).Width = 2
Dim BaRow As DataRow
BaRow =DataTables("备案登记").find("楼房编号= '" & Tables("楼面规划_table1").Rows(i)("楼房编号") & "'")
Dim DjRow As DataRow
DjRow =DataTables("登记购房明细").find("楼房编号= '" & Tables("楼面规划_table1").Rows(i)("楼房编号") & "'")
Dim ZmHzs As List(Of String)
ZmHzs =DataTables("楼面台账账面").SQLGetValues("购买户主","楼房编号= '" & Tables("楼面规划_table1").Rows(i)("楼房编号") & "'")
Dim SjRows As List(Of DataRow)
SjRows =DataTables("楼面台账收款").SQLSelect("楼房编号= '" & Tables("楼面规划_table1").Rows(i)("楼房编号") & "'")
rt.Cells(0,1).SpanCols = 3 '第5行第2个单元格向右合并3列
rt.Cells(2,5).SpanCols = 3 '第5行第2个单元格向右合并3列
'rt.Cells(1,0).SpanRows = 3 '第1行第5个单元格向下合并6行
rt.Cells(0,0).Text = "楼房位置"
rt.Cells(0,1).Text = dt1.Rows(i)("楼房编号")
rt.Cells(0,4).Text = "备案编号"
rt.Cells(0,6).Text = "备案户名"
rt.Cells(1,0).Text = "备案日期"
rt.Cells(1,2).Text = "面 积"
rt.Cells(1,4).Text = "单 价"
rt.Cells(1,6).Text = "金 额"
rt.Cells(2,0).Text = "联系电话"
rt.Cells(2,2).Text = "身份证号"
rt.Cells(2,4).Text = "户籍地址"
If BaRow IsNot Nothing Then
rt.Cells(0,5).Text = BaRow("备案编号")
rt.Cells(0,7).Text = BaRow("购买户主")
rt.Cells(1,1).Text = BaRow("备案日期")
rt.Cells(1,3).Text = BaRow("面积")
rt.Cells(1,5).Text = BaRow("单价")
rt.Cells(1,7).Text = BaRow("金额")
rt.Cells(2,1).Text = BaRow("联系电话")
rt.Cells(2,3).Text = BaRow("身份证号")
rt.Cells(2,5).Text = BaRow("户籍地址")
End If
Dim m As Integer = 0
For r As Integer = 0 To ZmHzs.Count - 1
Dim Rows As List(Of DataRow)
Rows =DataTables("楼面台账收款").SQLSelect("楼房编号= '" & Tables("楼面规划_table1").Rows(i)("楼房编号") & "' and 购买户主 = '" & ZmHzs(r) & "'")
rt.Cells(2 + 1 + m,0).SpanCols = 2 '第5行第2个单元格向右合并3列
rt.Cells(2 + 1 + m,0).Text = "第" & r + 1 & "户 户名:" & ZmHzs(r) & " 收据金额 " & Format(DataTables("楼面台账收款").SQLCompute("sum(收款金额)","楼房编号= '" & Tables("楼面规划_table1").Rows(i)("楼房编号") & "' and 购买户主 = '" & ZmHzs(r) & "'"),"#,###.00")
rt.RowGroups(2 + 1 + m,1).Style.BackColor = Color.LightGray
rt.rows(2 + 1 + m).Style.Font = New Font("黑体", 10 , FontStyle.Bold)
rt.Cells(2 + 1 + m,2).Text = "联系电话"
rt.Cells(2 + 1 + m,4).Text = "身份证号"
rt.Cells(2 + 1 + m,6).Text = "户籍地址"
rt.Cells(2 + 2 + m,0).Text = "付款账户"
rt.Cells(2 + 2 + m,1).Text = "付款账号"
rt.Cells(2 + 2 + m,2).Text = "金额"
rt.Cells(2 + 2 + m,3).Text = "收款账户"
rt.Cells(2 + 2 + m,4).Text = "收款账号"
rt.Cells(2 + 2 + m,5).Text = "收款日期"
rt.Cells(2 + 2 + m,6).Text = "核查情况"
rt.Cells(2 + 2 + m,7).Text = "待查原因"
If DjRow IsNot Nothing Then
rt.Cells(2 + 1 + m,3).Text = BaRow("联系电话")
rt.Cells(2 + 1 + m,5).Text = BaRow("身份证号")
rt.Cells(2 + 1 + m,7).Text = BaRow("户籍地址")
End If
'msgbox(Rows.Count - 1)
For n As Integer = 0 To Rows.Count - 1
rt.Cells(2 + 3 + m + n ,0).Text = Rows(n)("付款情况_付款户名")
rt.Cells(2 + 3 + m + n ,1).Text = Rows(n)("付款情况_付款账号")
rt.Cells(2 + 3 + m + n ,2).Text = Format(Rows(n)("收款金额"),"#,###.00")
rt.Cells(2 + 3 + m + n ,2).Style.TextAlignHorz = prt.AlignHorzEnum.right
rt.Cells(2 + 3 + m + n ,3).Text = Rows(n)("收款情况_收款户名")
rt.Cells(2 + 3 + m + n ,4).Text = Rows(n)("收款情况_收款账号")
rt.Cells(2 + 3 + m + n ,5).Text = Rows(n)("收款情况_收款日期")
rt.Cells(2 + 3 + m + n ,6).Text = Rows(n)("核查情况")
rt.Cells(2 + 3 + m + n ,7).Text = Rows(n)("待查原因")
rt.Cells(2 + 2 + m ,2).Style.TextAlignHorz = prt.AlignHorzEnum.Center
Next
m = m + Rows.Count + 2
'If m > 18
'rm.BreakBefore = prt.BreakEnum.Page
'End If
'doc.Body.Children.Add(rm)
'msgbox(m)
Next
msgbox(m)
Next
doc.PageSetting.Landscape = True '横向打印
Doc.Preview() '预览报表