Foxtable(狐表)用户栏目专家坐堂 → 专业报表补空行的问题


  共有4191人关注过本帖树形打印复制链接

主题:专业报表补空行的问题

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/5/21 20:54:00 [显示全部帖子]

测试了一下,发觉弄不了。只有固定每一行的行高,才能计算到确切要补多少行。

 

建议单独做一个文本框,给用户自己输入要补多少行吧,最能这样了。


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/5/23 12:07:00 [显示全部帖子]

 每页15行,按钮代码

 

'''
Dim doc As New PrintDoc '定义一个报表
Dim Mtb As Table = Tables("订单")
Dim CurRow As Row = Tables("订单").Current
Dim tb As Table = Tables("订单.订单明细")
Dim CW As String
Dim Cls As String()

'设置打印纸张
doc.PageSetting.PaperKind = 9  'A4
doc.PageSetting.Landscape = False '是否横向打印
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 8 '设置上边距
Doc.PageSetting.BottomMargin = 8 '设置下边距
'1----------------------------------------------------定义页眉---------------------------------------------------1
Dim ra As New prt.RenderArea '定义一个容器
'---先定义主标题
Dim rx As New prt.RenderText '定义一个文本对象
rx.Text = "中山市大立五金制品有限公司"
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rx.Style.Font = New Font("宋体", 18, FontStyle.Bold) '设置字体
rx.Style.Spacing.Bottom = 2 '和下一个对象的距离(毫米)
ra.Children.Add(rx) '将文本对象加入到容器ra中
rx = New prt.RenderText '再次新建一个文本框
rx.Text = "订 单"
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rx.Style.Font = New Font("宋体", 16, FontStyle.Bold) '设置字体
rx.Style.Spacing.Bottom = 2 '和下一个对象的距离(毫米)
ra.Children.Add(rx) '将文本对象加入到容器ra中
rx = New prt.RenderText '再次新建一个文本框
rx.Text = "订单类别: " & CurRow("订单类别")  &  "            编号:" & CurRow("编号") & "        客户: " & CurRow("客户")
' rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rx.Style.Font = New Font("宋体", 13) '设置字体
rx.Style.Spacing.Bottom = 2 '和下一个对象的距离(毫米)
ra.Children.Add(rx) '将文本对象加入到容器ra中

rx = New prt.RenderText '再次新建一个文本框
rx.Text = "一:订单的品名,数量,金额等如下:"
' rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rx.Style.Font = New Font("宋体", 13) '设置字体
rx.Style.Spacing.Bottom = 2 '和下一个对象的距离(毫米)
ra.Children.Add(rx) '将文本对象加入到容器ra中

'----设置以上部份作为页眉--------------------------------------
doc.PageHeader = ra '(页眉本身就是报表的一部份,不能再用语句加入到报表中会出错)

ra = New prt.RenderArea '定义一个容器
Dim rt As prt.RenderTable

Dim ColNames As String() = {"编号","品名","规格","数量","单位","备注"}
Dim drs As List(Of DataRow)
drs = Tables("订单.订单明细").DataTable.Select("编号 = " & CurRow("编号"))
If drs IsNot Nothing Then  '如果有值
    Dim prs As Integer = 15 '每页20行
    For p As Integer = 0 To math.Ceiling(drs.Count / prs) - 1
        rt = New prt.RenderTable '定义一个表格对象
        '指定总列数及各列宽,未指定的平分剩余宽度
        CW = "18|35|45|20|15"  '""
        Cls = CW.split("|")
        rt.Cols.Count = Cls.Length + 1 '设置总列数
        For i As Integer = 0 To Cls.Length-1
            rt.Cols(i).Width = Cls(i)
        Next
        '设置表格总体样式-------------------------------------------0
        rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本水平居中
        rt.Style.TextAlignVert = prt.AlignVertEnum.Center '文本垂直居中
        rt.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米
        rt.Style.GridLines.All = New prt.Linedef(0.2,Color.Black) '设置网格线
        rt.Style.Font = New Font("宋体", 11) '设置总体字体
        'rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止被垂直分割
        rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
       
        '设置明细表标题列-------------------------------------------1
        rt.Rows(rt.Rows.Count).Height = 15
        rt.Rows(rt.Rows.Count-1).Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本水平居中
        Dim nms As String() = {"编号","品名","规格","数量","单位","备注"}
        For c As Integer = 0 To nms.Length -1
            rt.Cells(rt.Rows.Count-1,c).Text = nms(c)
        Next
       
        For i As Integer = p * prs To math.min(drs.Count - 1,( p + 1) * prs - 1)
            rt.Rows(rt.Rows.Count).Height = 10
            For c As Integer = 0 To ColNames.Length -1
                If c = 0 Then
                    rt.cells(rt.Rows.Count-1,c).text = Format(i+1,"00")
                Else
                    rt.cells(rt.Rows.Count-1,c).text = drs(i)(ColNames(c))
                    If rt.cells(rt.Rows.Count-1,c).text = "0" Then '将0显示为空
                        rt.cells(rt.Rows.Count-1,c).text = ""
                    End If
                    'If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then '如果是数值或日期列
                    rt.cells(rt.Rows.Count-1,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '数据水平居中
                    ' Else
                    '    rt.cells(rt.Rows.Count-1,c).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平居中
                    ' End If
                End If
            Next
        Next
        If p = math.Ceiling(tb.Rows.Count / prs) - 1 '如果是最后一页
            For r As Integer = tb.Rows.Count To ( p + 1) * prs - 1 '补空行
                rt.Rows.Count = rt.Rows.Count + 1
                rt.Rows(rt.Rows.Count).Height = 10
                rt.Rows(rt.Rows.count -1)(0).text = " "
            Next
        Else
            rt.BreakAfter = prt.BreakEnum.Page '否则换页
        End If
        ra.Children.Add(rt) '将文本对象加入到容器ra中
    Next
End If

'设置表尾---------------------------------------------------1
rt.Rows(rt.Rows.Count).Height = 10
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体",11) '设置字体
'rt.Rows(rt.Rows.Count-1).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉网格线
'rt.Rows(rt.Rows.Count-1).Style.Borders.Top = New prt.LineDef("0.2mm", Color.Black) '恢复上方网格线
'rt.Cells(rt.Rows.Count-1,1).Style.Borders.left = New prt.LineDef("0mm", Color.white)
rt.Cells(rt.Rows.Count-1,0).SpanCols = 2
rt.Cells(rt.Rows.Count-1,0).Text = "合计数量:"
rt.Cells(rt.Rows.Count-1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Left '文本水平位置
rt.Cells(rt.Rows.Count-1,2).SpanCols = 4
rt.Cells(rt.Rows.Count-1,2).Text = CUMoney(DataTables("订单明细").Compute("Sum(数量)", "编号 = " & CurRow("编号")))
rt.Cells(rt.Rows.Count-1,2).Style.TextAlignHorz = prt.AlignHorzEnum.Left '文本水平位置
'-----------------------------------------------------------2
rt.Rows(rt.Rows.Count).Height = "auto"
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体",12) '设置字体
rt.Cells(rt.Rows.Count-1,0).SpanCols = 2
rt.Cells(rt.Rows.Count-1,0).Text = "备注:"
rt.Cells(rt.Rows.Count-1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本水平位置
'----------------------------------------------------------4

doc.Body.Children.Add(ra) '将表格对象加入到报表中

ra = New prt.RenderArea '定义一个容器
rx = New prt.RenderText '定义一个文本对象
Dim s As String
s = "二:供方应在确认的交期内供货,若逾期未交货,则按未交货金额的5%计算违约金.超过三天的,需方可以取消订单." & vbcrlf
s = s & "三:商品依需方所订立之检验标准进行验收,全部或部分不合格时,需方有权退货,由供方在限定期限内取回并及时补货,因退换货所发生的费用及其损失概由供方自行负担." & vbcrlf
s = s & "四:交货地点:需方仓库." & vbcrlf
s = s & "五:付款条件:月结   天." & vbcrlf
s = s & "六:其他要求:"
rx.Text = s
rx.Style.LineSpacing = 120 '设置双倍行距
' rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rx.Style.Font = New Font("宋体", 12) '设置字体
rx.Style.Spacing.Bottom = 8 '和下一个对象的距离(毫米)
ra.Children.Add(rx) '将文本对象加入到容器ra中
rx = New prt.RenderText '定义一个文本对象
rx.Text = "批准:                                            审核:                                           制单"
ra.Children.Add(rx) '将文本对象加入到容器ra中

'---显示页数
rt = New prt.RenderTable
rt.Cells(0,0).Text = Date.Today
rt.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页"
rt.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rt.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
rt.Style.Borders.Bottom = New prt.LineDef '设置底边框
rt.CellStyle.Spacing.Top = 0.5 '底端内容缩进0.5毫米
rt.Style.FontSize = 8 '字体大小为8磅
ra.Children.Add(rt) '将文本对象加入到容器ra中
'设置以上部份作为页脚--------------------------------------5
doc.PageFooter = ra '(页脚本身就是报表的一部份,不能再用语句加入到报表中会出错)
'  doc.Body.Children.Add(rt) '将表格对象加入到报表中
Doc.Preview() '预览报表


 回到顶部