Dim Names As List(Of String) = Tables("订单").DataTable.GetValues("产品")
Dim doc As New PrintDoc
Dim rt As New prt.RenderTable
rt.Cells(0,0).Text = "产品"
rt.Cells(0,0).SpanRows = 2
rt.Cells(0,1).Text = "订购次数"
rt.Cells(0,1).SpanRows = 2
rt.Cells(0,2).Text = "数量"
rt.Cells(0,2).SpanRows = 2
rt.Cells(0,3).Text = "金额"
rt.Cells(0,3).SpanCols = 12
Dim str() As String = {"十","亿","千","百","十","万","千","百","十","元","角","分"}
For i As Integer = 0 To str.Length -1
rt.Cols(3+i).Width = 6
rt.Cells(1,3+i).Text = str(i)
Next
For i As Integer = 0 To Names.Count -1
rt.Cells(i+2,0).Text= Names(i)
rt.Cells(i+2,1).Text = Tables("订单").DataTable.Compute("Count(日期)","产品='" & Names(i) & "'")
rt.Cells(i+2,2).Text = Tables("订单").DataTable.Compute("Sum(数量)","产品='" & Names(i) & "'")
Dim je As Double = Tables("订单").DataTable.Compute("Sum(金额)","产品='" & Names(i) & "'")
Dim jes As String = Format(je,"#.00").Replace(".","").PadLeft(12)
For j As Integer = 0 To jes.Length -1
rt.Cells(i+2,3+j).Text = jes(j)
Next
'rt.Cells(i+1,3).Text =
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
rt.CellStyle.Spacing.All = 1 '内容距离网格线1毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
doc.Body.Children.Add(rt)
doc.Preview()