试试这样改一下
Dim doc As New PrintDoc '定义一个新报表
Dim rt As New prt.RenderTable '定义一个新表格
Dim tb As Table = Tables("订单群")
Dim ColNames As String() = New String(){"日期", "客户", "产品","厚度","宽度","长度","单价","数量","价格"}
rt.Style.Font = tb.Font
For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
rt.Cells(0,c).Text = ColNames(c) '列名作为标题
rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth '列宽等于实际列宽
If tb.Cols(ColNames(c)).IsNumeric Then '如果是数值
rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
End If
If tb.Cols(ColNames(c)).IsNumeric Then '如果是数值
For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
rt.Cells(r + 1, c).Text = Format(tb.Rows(r)(ColNames(c)), "#.##")
Next
Else
For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
Next
End If
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
doc.Body.Children.Add(rt) '将表格加入到报表
'如果需要分栏打印,请加上下面两行
'doc.Columns.Add()
'doc.Columns.Add()
doc.Preview()