分组打印

打印客户表,按地区分组打印,代码如下:

Dim doc As New PrintDoc
Dim
rt As Prt.RenderTable
Dim
rx As prt.RenderText
Dim
tbl As Table = Tables("客户")
Dim
Rows As List(Of DataRow)
Dim
Regions As List(Of String) = tbl.DataTable.GetValues("地区")
doc
.Pagesetting.LandScape = True
For Each
Region As String In Regions
   
rx = New prt.RenderText
   
rx.Style.FontSize = 14
   
rx.Style.FontBold = True
    rx
.Style.Spacing.Bottom =
2
   
rx.Text = "地区: " & Region
   
doc.Body.Children.Add(rx)
    rt
= New prt.
RenderTable
   
rt.Style.Font = Tables("客户").Font
   
rt.Style.TextAlignVert = prt.AlignVertEnum.Center
   
rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
    rt
.Style.Spacing.Bottom =
5
   
rt.CellStyle.Spacing.All = 1
    rt.Style.Font = tbl.Font
    Rows = tbl.Datatable.Select("[地区] = '" & Region & "'")
    For
c As integer = 0 To tbl.Cols.Count - 1
       
rt.Cells(0,c).Text = tbl.Cols(c).Name
        rt
.Cols(c).Width = tbl.Cols(c).
PrintWidth
        For
r As integer = 0 To Rows.Count -1
            rt
.Cells(r + 1, c).Text = rows(r)(tbl.Cols(c).Name
)
        Next
    Next

    rt.RowGroups(
0,1).Header = prt.TableHeaderEnum.All
   
doc.Body.Children.Add(rt)
Next

doc
.preview()

打印效果:

 


本页地址:http://www.foxtable.com/webhelp/topics/1235.htm