-- 作者:狐狸爸爸
-- 发布时间:2012/7/19 6:19:00
--
你的将这两个表发上来给相帮你的人调试,将订单处理和打包内容发上来即可,就是这段代码要打印的两个表,不要动辄将整个项目上传。
否则只能蒙一下:
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 rs As New prt.RenderText() \'定义一个文本对象 rs.Text = "表格标题" \'设置文本对象的内容 rs.Style.Font = New Font("宋体", 24 , FontStyle.Bold) \'设置文本对象的字体 rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'文本内容水平居中 doc.Body.Children.Add(rs) \'将文本对象加入到表格中
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("订单处理") Dim cnt As Integer = 0 For Each cr As DataRow In crs If cr("ischeck") = 5 Then cnt =cnt + 1 End If Next If cnt> 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 If crs(n)("ischeck") = 5 Then 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 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 rt.cols(0).Width = 100 doc.Preview() \'预览报表 doc.SaveHtm("c:\\data\\sky.htm")
[此贴子已经被作者于2012-7-19 6:27:43编辑过]
|