加上这几行红色部分,表格就好看了
Dim doc As New PrintDoc
Dim tb As Table = Tables("表A")
For p As Integer = 0 To math.Ceiling(tb.Rows.Count / 5) - 1 '每页5行
Dim rx As New prt.RenderText
rx.Text = "人事工资表"
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rx.Style.Font = New Font("宋体", 16, FontStyle.Bold) '设置字体
rx.Style.Spacing.Bottom = 6 '设置下间隔为3毫米
doc.Body.Children.Add(rx)
Dim rt As New prt.RenderTable
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 0.5
rt.Cells(0,0).Text = "第一列"
rt.Cells(0,1).text = "第二列"
For r As Integer = p * 5 To math.min(tb.Rows.Count - 1,(p+1) * 5 - 1)
rt.Cells(r - p * 5 + 1,0).Text = tb.rows(r)("第一列")
rt.Cells(r - p * 5 + 1,1).text = tb.rows(r)("第二列")
Next
If p < math.Ceiling(tb.Rows.Count / 5) - 1
rt.BreakAfter = prt.BreakEnum.Page
End If
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中
doc.Body.Children.Add(rt)
Next
doc.Preview()