Dim doc As New PrintDoc '定义一个报表
Dim tbl As Table = Tables("未满箱明细_table1")
For i As Integer = tbl.Toprow To tbl.BottomRow
Dim rw As Row = tbl.Rows(i)
Dim ra As New prt.RenderArea
Dim rt As New prt.RenderTable() '定义一个表格对象
Dim rx As New prt.RenderText '定义一个文本对象
Dim Rows As List(Of DataRow) '定义行集合
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距
rx.text = "未满箱明细"
rx.Style.FontBold = True '字体加粗
rx.Style.FontSize = 16 '大体大小为16磅
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
rx.Style.Spacing.Bottom = 3 '和下面的对象(表格)距离3毫米
doc.Body.Children.Add(rx) '加入到报表中
MessageBox.Show(1)
Dim ColNames As String() = New String(){"客人名称","款号","客人订单号","客人交期","数量","已完成数量","已出货数量","库存数量"}
Dim MergeCols As Integer = 4 '指定要合并的列数
tbl.Sort = "客人名称,款号,前幅,后幅" '根据合并列排序
rt.Width = "Auto"
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded
rt.Style.Font = tbl.Font
rt.Style.TextAlignVert = prt.AlignVertEnum.Center
rt.RepeatGridLinesVert = True '换页后重复表格线
MessageBox.Show(2)
For c As Integer = 0 To ColNames.Length - 1
Dim lr As Integer ' 用于保存合并区域的起始行
rt.Cells(0,c).Text = ColNames(c)
rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Cols(c).Width = tbl.Cols(ColNames(c)).PrintWidth
If tbl.Cols(ColNames(c)).IsNumeric OrElse tbl.Cols(ColNames(c)).IsDate Then
rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right
End If
MessageBox.Show(3)
For r As Integer = 0 To tbl.Rows.Count - 1
If c <= MergeCols - 1 Then '如果是要合并的列
Dim Merge As Boolean = True
If r = 0 Then
Merge = False
Else
For n As Integer = 0 To c
If tbl.Rows(r)(ColNames(n)) <> tbl.Rows(r - 1)(ColNames(n))
Merge = False
Exit For
End If
Next
End If
If Merge Then
rt.Cells(lr,c).SpanRows = rt.Cells(lr,c).SpanRows + 1
Else
rt.Cells(r + 1, c).Text = tbl.Rows(r)(ColNames(c))
rt.Cells(r + 1, c).VertSplitBehavior = prt.CellSplitBehaviorEnum.Copy '换页后重复单元格
lr = r + 1
End If
Else
rt.Cells(r + 1, c).Text = tbl.Rows(r)(ColNames(c))
End If
Next
Next
MessageBox.Show(4)
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 0.5
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never
MessageBox.Show(5)
rt.Cells(i+ 1,2).Image = GetImage(rw("前幅"))
rt.Cells(i+ 1,3).Image = GetImage(rw("后幅"))
doc.Body.Children.Add(rt)
ra.Children.Add(rt)
Doc.Body.ChildRen.Add(ra)
Next
MessageBox.Show(6)
doc.Preview()
执行后显示 3 后就不再显示了,是不是第4段出了问题