以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 窗口打印 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=90964) |
-- 作者:lk15502 -- 发布时间:2016/9/26 16:06:00 -- 窗口打印 窗口的中间是订单明细表,上面和下面绑定了订单表的几个字段,右下角有个打印按钮,打印预览只打印了中间的表,上下的绑定数据没有显示,请问老师如何解决;能够打印整个窗口, 还有如何排除空的列 Dim doc As New PrintDoc Dim rt As New prt.RenderTable Dim tb As Table = Tables("生产计划单_table1") Dim ColNames As String() = New String(){"生产品名规格", "颜色意见","客户款号","客户订单号","订单重量","生产计划重量"} Dim MergeCols As Integer = 2 \'指定要合并的列数 tb.Sort = "生产品名规格,颜色意见" \'根据合并列排序 rt.Width = "Auto" rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded rt.Style.Font = tb.Font rt.Style.TextAlignVert = prt.AlignVertEnum.Center rt.RepeatGridLinesVert = True \'换页后重复表格线 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 = tb.Cols(ColNames(c)).PrintWidth If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right End If For r As Integer = 0 To tb.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 tb.Rows(r)(ColNames(n)) <> tb.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 = tb.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 = tb.Rows(r)(ColNames(c)) End If Next Next 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 doc.Body.Children.Add(rt) doc.PageSetting.Landscape = True \'横向打印 doc.Preview() |
-- 作者:有点蓝 -- 发布时间:2016/9/26 16:26:00 -- 这个打印代码跟窗口打印有什么关系? |
-- 作者:lk15502 -- 发布时间:2016/9/26 16:41:00 -- 改了代码,出现了两个重叠的表,怎么排除,原来的没有合并单元格的表 Dim doc As PrintDoc = e.Form.gernateprintdoc() Dim rt As New prt.RenderTable Dim tb As Table = Tables("生产单_table1") Dim ColNames As String() = New String(){"订单品名规格", "颜色意见","客户款号","客户订单号","订单重量"} Dim MergeCols As Integer = 2 \'指定要合并的列数 tb.Sort = "订单品名规格,颜色意见" \'根据合并列排序 rt.Width = "Auto" rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded rt.Style.Font = tb.Font rt.Style.TextAlignVert = prt.AlignVertEnum.Center rt.RepeatGridLinesVert = True \'换页后重复表格线 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 = tb.Cols(ColNames(c)).PrintWidth If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right End If For r As Integer = 0 To tb.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 tb.Rows(r)(ColNames(n)) <> tb.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 = tb.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 = tb.Rows(r)(ColNames(c)) End If Next Next 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 doc.Body.Children.Add(rt) doc.PageSetting.Landscape = True \'横向打印 doc.Preview() |
-- 作者:有点蓝 -- 发布时间:2016/9/26 16:57:00 -- 没搞懂你要做什么,上例子说明 |
-- 作者:lk15502 -- 发布时间:2016/9/26 17:00:00 -- 老师,就是想打印窗口,然后窗口中的表的前两列合并单元格,同时排除空的列 |
-- 作者:有点蓝 -- 发布时间:2016/9/26 17:02:00 -- 上例子说明 |