Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim re As prt.RenderText
Dim tbl As Table = Tables("订单")
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String()) = tbl.DataTable.GetUniqueValues("","客户","产品","雇员")
doc.Pagesetting.LandScape = True
For Each Region As String() In Regions
rx = New prt.RenderText
rx.Text = "客户: " & Region(0) & "," & region(1) & "," & region(2)
rx.Style.FontBold = True
rx.Style.Spacing.Bottom = 3
doc.Body.Children.Add(rx)
re = New prt.RenderText
re.Text= "合计:[Aggregates!GroupSum.Value]"
re.Style.FontBold = True
re.Style.Spacing.Bottom = 3
doc.Body.Children.Add(re)
rt = New prt.RenderTable
rt.Style.GridLines.All = New prt.Linedef
rt.Cols.Count = 10
rt.Style.Font = Tables("订单").Font
rt.Style.Font = tbl.Font
Rows = tbl.Datatable.Select("[客户] = '" & Region(0) & "'and [产品] = '" & Region(1) & "'and [雇员] = '" & Region(2) & "'")
Dim ColNames As String() = New String(){"数量"}
For r As integer = 0 To Rows.Count -1 '开始填入该列内容
select case r
case 0
rt.Cells(0, r).Text = Rows(r)(ColNames(0))
case 1 to 9
rt.Cells(0, r).Text = Rows(r)(ColNames(0))
rt.Style.Spacing.All = 1
case 10 to 19
rt.Cells(1, r-10).Text = Rows(r)(ColNames(0))
case 20 to 29
rt.Cells(2, r-20).Text = Rows(r)(ColNames(0))
case 30 to 39
rt.Cells(3, r-30).Text = Rows(r)(ColNames(0))
case 40 to 49
rt.Cells(4, r-40).Text = Rows(r)(ColNames(0))
case 50 to 59
rt.Cells(5, r-50).Text = Rows(r)(ColNames(0))
case 60 to 69
rt.Cells(6, r-60).Text = Rows(r)(ColNames(0))
case 70 to 79
rt.Cells(7, r-70).Text = Rows(r)(ColNames(0))
end select
Next
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
doc.Body.Children.Add(rt)
Next
doc.preview()
基本上搞定,应该可以代替部分分栏效果,就是合计如何放在右侧上方,与客户并列,一个在左,一个在右?
Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim re As prt.RenderText
Dim re1 As prt.RenderText
Dim tbl As Table = Tables("发货清单明细")
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String()) = tbl.DataTable.GetUniqueValues("","颜色","颜色编号","幅宽","克重","单价") '"卷长","金额")
Dim Regi As List(Of String) = tbl.DataTable.GetUniqueValues("","客户")
Dim Regio As List(Of String) = tbl.DataTable.GetUniqueValues("","发货日期")
doc.Pagesetting.LandScape = True
dim sum1 as single=0
dim sum3 as single=0
dim sum2 as single=0
dim count as short=0
re = New prt.RenderText
re.Text= "发货结算单"
're.Style.FontBold = True
're.Style.Spacing.Bottom = 3
re.Style.FontSize = 16
re.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
doc.Body.Children.Add(re)
Dim rx1 As New prt.RenderTable
rx1.Cells(0,0).Text = "客户:" & regi(0)
rx1.Cells(0,1).Text = "发货日期:" & regio(0).SubString(0,9)
rx1.Cells(0,2).Text = "货单号: ."
rx1.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx1.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx1.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.right
rx1.Style.Borders.Bottom = New prt.LineDef (0.3, color.gray)'设置底边框
rx1.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
'rx1.Style.FontSize = 8 '字体大小为8磅
rx1.Style.Spacing.top = 2
'Doc.PageHeader = rx1
doc.Body.Children.Add(rx1)
'dim f As integer=0
Dim rf As new Prt.RenderTable
rf.Style.TextAlignHorz = prt.AlignHorzEnum.center
rf.Cols(0).Width = 8
rf.Cols(1).Width = 32
rf.Cols(2).Width = 30
rf.Cols(3).Width = 14
rf.Cols(4).Width = 20
rf.Cols(5).Width = 14
rf.Cols(6).Width = 20
rf.Cols(7).Width = 14
rf.width="auto"
rf.cells(0,0).text="编号"
rf.cells(0,1).text="颜色编号"
rf.cells(0,2).text="规格"
rf.cells(0,3).text="件数"
rf.cells(0,4).text="重量"
rf.cells(0,5).text="单价"
rf.cells(0,6).text="金额"
rf.cells(0,7).text="备注"
doc.Body.Children.Add(rf)
dim f As integer=0
For Each Region As String() In Regions
dim sum as single=0
'dim f As integer=0
rt = New prt.RenderTable
'rt.Style.GridLines.All = New prt.Linedef(0.1, color.gray)
'rt.Cols.Count = 15
'rt.style.WordWrap=true
'rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
Rows = tbl.Datatable.Select("[颜色] = '" & Region(0) & "'and [颜色编号] = '" & Region(1) & "'and [幅宽] = '" & Region(2) & "'and [克重] = '" & region(3) & "'and [单价] = '" & region(4) & "'")
Dim ColNames As String() = New String(){"重量"}
For r As integer = 0 To Rows.Count -1 '开始填入该列内容
count=0
select case r
case 0
rt.Cells(0, r).Text = Rows(r)(ColNames(0))
sum=sum+Rows(r)(ColNames(0))
count=1
case 1 to 14
rt.Cells(0, r).Text = Rows(r)(ColNames(0))
sum=sum+Rows(r)(ColNames(0))
case 15 to 29
rt.Cells(1, r-15).Text = Rows(r)(ColNames(0))
sum=sum+Rows(r)(ColNames(0))
count=count+1
case 30 to 44
rt.Cells(2, r-30).Text = Rows(r)(ColNames(0))
sum=sum+Rows(r)(ColNames(0))
count=count+1
case 45 to 59
rt.Cells(3, r-45).Text = Rows(r)(ColNames(0))
sum=sum+Rows(r)(ColNames(0))
count=count+1
case 60 to 74
rt.Cells(4, r-60).Text = Rows(r)(ColNames(0))
sum=sum+Rows(r)(ColNames(0))
count=count+1
case 75 to 89
rt.Cells(5, r-75).Text = Rows(r)(ColNames(0))
sum=sum+Rows(r)(ColNames(0))
count=count+1
end select
'rt.Cells(0,10).SpanRows = count
next
sum=sum*0.976
rf = New prt.RenderTable
rf.Style.TextAlignHorz = prt.AlignHorzEnum.center
rf.Style.GridLines.All = New prt.Linedef(0.1, color.gray)
'rf.height=8
rf.cols(0).style.fontsize = 12 '设置行高
rf.Cols(0).Width = 8
rf.Cols(1).Width = 32
rf.Cols(2).Width = 30
rf.Cols(3).Width = 14
rf.Cols(4).Width = 20
rf.Cols(5).Width = 14
rf.Cols(6).Width = 20
rf.Cols(7).Width = 14
rf.width="auto"
rf.cells(f+1,1).text=region(0) & "," & region(1)
rf.cells(f+1,2).text=region(2) & "*" & region(3) & "g*2222m"
rf.cells(f+1,3).text=rows.count & "件"
rf.cells(f+1,4).text=math.round(sum,2) & "kg"
rf.cells(f+1,5).text=region(4)
rf.cells(f+1,6).text=Tables("发货清单明细").DataTable.Compute("Sum(金额)","[颜色] = '" & Region(0) & "'and [颜色编号] = '" & Region(1) & "'and [幅宽] = '" & Region(2) & "'and [克重] = '" & region(3) & "'and [单价] = '" & region(4) & "'")
rf.cells(f+1,0).text=f+1
f=f+1
doc.Body.Children.Add(rf)
' rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
'doc.Body.Children.Add(rt)
'next
sum1=sum1+sum
sum2=sum2+Rows.Count
sum3=sum3+Tables("发货清单明细").DataTable.Compute("Sum(金额)","[颜色] = '" & Region(0) & "'and [颜色编号] = '" & Region(1) & "'and [幅宽] = '" & Region(2) & "'and [克重] = '" & region(3) & "'")
next
re1 = New prt.RenderText
re1.Text= "总重量:" & sum1 & "公斤 总件数" & sum2 & "件"
re1.Style.Spacing.top = 5
re1.Style.FontSize = 12
doc.Body.Children.Add(re1)
rx = New prt.RenderText
rx.Text = "金额: " & sum3 'Tables("发货清单明细").DataTable.Compute("Sum(金额)","[颜色] = '" & Region(0) & "'and [颜色编号] = '" & Region(1) & "'and [幅宽] = '" & Region(2) & "'and [克重] = '" & region(3) & "'")
'Region(0) & "," & region(1) & "," & region(2) & "," & region(3) & " 重量:" & sum & " 件数" & Rows.Count
rx.Style.FontBold = True
rx.Style.Spacing.top = 3
doc.Body.Children.Add(rx)
doc.PageSetting.Width = 175 '纸张宽度为100毫米
doc.PageSetting.Height = 255 '纸张高度为120毫米
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 20 '设置上边距
Doc.PageSetting.BottomMargin = 20 '设置下边距
doc.preview()
[此贴子已经被作者于2010-4-8 0:10:36编辑过]