代码如下:需要改进如下3个问题。
1 设置第一列的列宽为 100
2 添加一个条件, 表格中只显示 《订单处理》表中[ischeck] 列的值为5 的数据。
3 添加一个动态标题: 标题名为 dr(“用户名”)& 发货清单
非常非常感谢!!!!!
Dim doc As New PrintDoc
Dim rt As New prt.RenderTable()
Doc.PageSetting.LeftMargin = 5 '设置左边距
Doc.PageSetting.RightMargin = 5 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 5 '设置下边距
Dim rx As New prt.RenderTable
rx.Cells(0,0).Text = Date.Today
rx.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页"
rx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
rx.Style.Borders.Bottom = New prt.LineDef '设置底边框
rx.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
rx.Style.FontSize = 15 '字体大小为8磅
Doc.PageHeader = rx '作为页眉使用
rt.Cols.Count = 5
rt.Style.Font = New Font("宋体", 15 , FontStyle.Bold) '设置文本对象的字体
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中
rt.Style.Borders.All = New prt.Linedef(0, Color.Lavender) '设置边框
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中
doc.Body.Children.Add(rt)
rt.Style.GridLines.All = New prt.Linedef
For i As Integer = Tables("打包内容").TopPosition To Tables("打包内容").BottomPosition
Dim dr As DataRow = Tables("打包内容").Rows(i).DataRow
Dim crs As List(of DataRow) = dr.GetChildRows("订单处理")
If crs.count > 0 Then
rt.Rows.Count = rt.Rows.count +1
Dim st As Integer = rt.Rows.count - 1 '起始行位置
Dim nt As Integer = st '当前行位置
Dim cp As Integer = 2 '当前列位置
rt.cells(st+1,0).text = dr("商城")
rt.cells(st+1,1).text = dr("商号")
rt.cells(nt+2,0).text = "商品名"
rt.cells(nt+2,1).text = "颜色"
rt.cells(nt+2,2).text = "大小"
rt.cells(nt+2,3).text = "数量"
For n As Integer = 0 To crs.count - 1
rt.cells(nt+3,0).text = crs(n)("商品名")
rt.cells(nt+3,1).text = crs(n)("color")
rt.cells(nt+3,2).text = crs(n)("weight")
rt.cells(nt+3,3).text = crs(n)("数量")
nt = nt + 1
If nt = 3 Then
nt=2
nt = nt + 2
End If
Next
rt.Cells(st+1,0).Style.BackColor = Color.pink
rt.Cells(st+1,1).Style.BackColor = Color.pink
rt.Cells(st+1,2).Style.BackColor = Color.pink
rt.cells(nt+2,cp).Style.FontSize = 10 '字体大小为8磅
End If
Next
doc.Preview() '预览报表
doc.SaveHtm("c:\data\sky.htm")
[此贴子已经被作者于2015/11/1 12:03:59编辑过]