Dim doc As New Printdoc
Dim rx,rx1 As new prt.RenderText
Dim rt As New prt.RenderTable() '定义一个表格对象
Dim prs As Integer = 9 '每页9行
Dim tb As Table = Tables("订单.订单明细")
Dim sum1 As Double = 0
Dim sum2 As Double = 0
Dim rs As Integer = Tables("订单.订单明细").Rows.Count
rx.text =" 订单编号: " & Tables("订单").Current("订单编号")
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rx.Style.Font = New Font("宋体", 16, FontStyle.Bold)
doc.Body.Children.Add(rx)
For p As Integer = 0 To math.Ceiling(rs/prs) - 1
rt.Cols.Count = 4 '设置rt行列数
rt.Rows.Count = 9
rt.Height = 130
For i As Integer = 0 To 13
rt.Rows(i).Height = 10 '设置rt行高
Next
rt.Rows(0).Style.Borders.bottom = New prt.Linedef '设置rt行格式
rt.Rows(1).Style.Borders.bottom = New prt.Linedef
rt.Rows(2).Style.Borders.bottom = New prt.Linedef
rt.Rows(3).Style.Borders.bottom = New prt.Linedef
rt.Rows(4).Style.Borders.bottom = New prt.Linedef
rt.Rows(5).Style.Borders.bottom = New prt.Linedef
rt.Rows(6).Style.Borders.bottom = New prt.Linedef
rt.Rows(7).Style.Borders.bottom = New prt.Linedef
rt.Rows(8).Style.Borders.bottom = New prt.Linedef
rt.Rows(9).Style.Borders.bottom = New prt.Linedef
rt.Cells(0,0).Text = "产品" '设置rt表头
rt.Cells(0,1).Text = "单价"
rt.Cells(0,2).Text = "数量"
rt.Cells(0,3).Text = "金额"
rt.Cells(10,2).Text = " 数量: " & sum1
For r As Integer = 0 To tb.Rows.Count - 1 '遍历关联表每一行
rt.Cells(r+1,0).Text = tb.rows(r)("产品")
rt.Cells(r+1,1).Text = tb.rows(r)("单价")
rt.Cells(r+1,2).Text = tb.rows(r)("数量")
rt.Cells(r+1,3).Text = tb.rows(r)("金额")
Next
sum1 = 0
sum2 = 0
For r As Integer = p * prs To math.min(rs - 1,( p + 1) * prs - 1)
sum1 =sum1 + tb.rows(r)("数量")
Next
If p < math.Ceiling(rs/ prs) - 1
rt.BreakAfter = prt.BreakEnum.Page
End If
doc.Body.Children.Add(rt)
Next
rx1.text =" 白色 深红 浅蓝 浅黄 浅绿 浅红 "
rx1.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rx1.Style.Font = New Font("宋体", 12, FontStyle.Bold)
doc.Body.Children.Add(rx1)
doc.Preview
[此贴子已经被作者于2011-11-28 13:52:21编辑过]