Dim doc As New PrintDoc '定义一个新报表
'Dim rt As New prt.RenderTable '定义一个新表格
Dim rt As New prt.RenderTable() '定义一个表格对象
Dim rx As New prt.RenderText '定义一个文本对象
'Dim doc As New PrintDoc() '定义一个报表
'doc.PageSetting.Width = 130 '纸张宽度为100毫米
'doc.PageSetting.Height = 196 '纸张高度为120毫米
'Doc.PageSetting.LeftMargin = 1 '设置左边距
'Doc.PageSetting.RightMargin = 1 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距
rt.Width =150 ' "Parent.Width" '对象宽度等于页面宽度
rt.Height = "Parent.Height" '对象高度
'Dim CurRow As Row = Tables("xiaoshoudanhao.xiaoshou").Current
'加入标题
rx.text = "丽 颜 销 售 单"
rx.Style.FontBold = True '字体加粗
rx.Style.FontSize = 16 '大体大小为16磅
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
'rx.Style.Spacing.Bottom = 20 '和下面的对象(表格)距离3毫米
doc.Body.Children.Add(rx) '加入到报表中
Dim tb As Table = Tables("xiaoshoudanhao.xiaoshou") '这个地方应该怎么改
Dim ColNames As String() = New String(){"name", "shuliang", "markprice", "dc", "price", "xiaoji"}
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font
For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
rt.Cells(0,0).Text = "商品名"
rt.Cells(0,1).Text = "数量"
rt.Cells(0,2).Text = "市场价"
rt.Cells(0,3).Text = "折扣"
rt.Cells(0,4).Text = "售价"
rt.Cells(0,5).Text = "小计" '列名作为标题
' rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth '列宽等于实际列宽
If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then '如果是数值或日期列
' rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.center '数据水平靠右
rt.cols(c).Style.TextAlignVert = prt.AlignHorzEnum.Center
rt.cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Center
End If
For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
Next
Next
Dim CurRow As Row = Tables("xiaoshoudanhao.xiaoshou").Current
Dim rt2 As New prt.RenderTable()
doc.Body.Children.Add(rt)
rt2.Style.GridLines.All = New prt.LineDef
rt2.Width = 150
rt2.Height = 20
rt.X= 20
rt.Y = 50
rt2.X= 20
rt2.Y =20
rt2.Cells(0,0).Text = "销售单号"
rt2.Cells(0,1).Text = CurRow("xiaoshoudanhao")
rt2.Cells(1,0).Text = "销售日期"
rt2.Cells(1,1).Text = CurRow("time")
rt2.Cells(1,0).Text = "客户名"
rt2.Cells(1,1).Text = CurRow("user")
rt2.Cells(0,4).Text = "货款总金额"
rt2.Cells(0,5).Text = Tables("xiaoshoudanhao.xiaoshou").compute("Sum(xiaoji)") 'CurRow("xiaoji")
rt2.Cells(0,2).Text = "商品总数量"
rt2.Cells(0,3).Text = Tables("xiaoshoudanhao.xiaoshou").compute("Sum(shuliang)")
rt2.Cells(1,2).Text = "已付款金额"
rt2.Cells(1,4).Text = "剩余金额"
rt2.Style.Font = New Font("宋体", 8, FontStyle.Bold)
rt2.Style.TextAlignVert = prt.AlignHorzEnum.Center
rt2.Style.TextAlignHorz = prt.AlignHorzEnum.Center
'rt2.Style.Spacing.Bottom = 13 '和下面的对象(表格)距离3毫米
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
'rt.CellStyle.Spacing.All = 5 '单元格内距设为0.5毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
doc.Body.Children.Add(rt2)
doc.Preview()