还是把代码贴一下,方便有需要的后来者
Dim Doc As New PrintDoc
Doc.PrinterName = "\\2011-20120311rn\EPSON LQ-735K ESC/P2"
Doc.PageSetting.Width =218
Doc.PageSetting.Height =138
Doc.AutoRotate = False
Doc.PageSetting.TopMargin=4
Doc.PageSetting.BottomMargin=2
Doc.PageSetting.LeftMargin=5
Doc.PageSetting.RightMargin=0
Doc.PageSetting.Landscape = True
Doc.AutoRotate = False
Dim prs As Integer = 15 '每页行数
Dim icou As Integer
Dim tb As Table = Tables("销售出库单主表.销售出库单子表")
Dim rx As New prt.RenderTable
rx.Width = 201
rx.Height = 93.5
rx.Style.Font = New Font("宋体", 9)
For p As Integer = 0 To Math.Ceiling((tb.Rows.Count / prs) - 1 )
Dim hd As Integer = tb.HeaderRows
Dim cnt As Integer
tb.CreateReportHeader(rx,True)
For c As Integer = 0 To tb.Cols.Count - 1
If tb.Cols(c).Visible
For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
rx.Cells(r - p * prs + hd, cnt).Text = tb.rows(r)(c)
rx.Cells(r - p * prs + hd,9).Text = "***"
rx.Cells(r - p * prs + hd,8).Text = "***"
rx.Cells(r - p * prs + hd,3).Style.TextAlignHorz =prt.AlignHorzEnum.Center
Next
If p < math.Ceiling(tb.Rows.Count / prs) - 1
rx.BreakAfter = prt.BreakEnum.Page
End If
cnt = cnt+1
End If
Next
rx.Cols.Insert(0) '在左边插入一列,用于打印行号
rx.Cols(0).Width = 8 '设置行号列的宽度
For i As Integer = 1 To rx.Rows.Count -hd
rx.Cells(i+1,0).text = i '逐行写入行号
icou = i +1
Next
If icou < 15 Then
rx.Cells(icou+1,0).text = "" '逐行写入行号
rx.Rows(icou+1).Height = (15-icou+1) * 5.5 '第7行的高度为50毫米
End If
Next
rx.Cells(0,0).SpanRows = 2'第1行第1个单元格向下合并2行
rx.Cells(0,0).Text = "№"
rx.Cols(0).Style.TextAlignHorz= prt.AlignHorzEnum.Center
rx.Cols(0).Style.TextAlignVert =prt.AlignVertEnum.Center
rx.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
rx.Style.GridLines.All = New prt.Linedef(0.1, Color.black)
doc.Body.Children.Add(rx) '
doc.Preview()
[此贴子已经被作者于2013-3-9 10:39:11编辑过]