Dim doc As New PrintDoc Dim rt As New prt.RenderTable Dim tb as Table = Tables("订单") tb.Sort = "产品,客户,雇员" 'rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All rt.Style.Font = tb.Font rt.Style.GridLines.All = prt.Linedef.Default rt.CellStyle.Spacing.All = 1 rt.Style.TextAlignVert = prt.AlignVertEnum.Center rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center Dim FirstRow As Integer = 1 rt.Cells(0,0).Text = "产品" rt.Cells(0,1).Text = "客户" rt.Cells(0,2).Text = "雇员" For r As integer = 0 To tb.Rows.Count -1 If tb(r,0) Is Nothing Then Continue for End if rt.Cells(r+1, 1).Text = tb(r,1) rt.Cells(r+1, 2).Text = tb(r,2) rt.Cells(r+1, 3).Text = tb(r,3) If r > 0 AndAlso tb(r,0) = tb(r-1,0) Then rt.Cells(FirstRow,0).SpanRows = rt.Cells(FirstRow,0).SpanRows + 1 if tb(r,1) = tb(r-1,1) then rt.Cells(FirstRow,1).SpanRows = rt.Cells(FirstRow,1).SpanRows + 1 end if if tb(r,2) = tb(r-1,2) then rt.Cells(FirstRow,2).SpanRows = rt.Cells(FirstRow,2).SpanRows + 1 end if Else rt.Cells(r+1, 0).Text = tb(r,0) FirstRow = r + 1 End if Next doc.Body.Children.Add(rt) doc.Preview()
|