以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  打印报表请教  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=169956)

--  作者:cjl333333333
--  发布时间:2021/7/7 15:07:00
--  打印报表请教

 Dim rt As New prt.RenderTable \'定义一个新表格
        Dim tb As Table = Tables("库存表主表.库存表")
        \'Dim prs As Integer = 5
        Dim ColNames As String() = New String(){"客户单号","生产单号","编号","名称","类型","出库数量","单位","出库件数","包装","备注"}
        Dim ColNames1 As String() = New String(){"客户PO/批号","生产单号","产品编码","产品名称","产品类型","数量","单位","件数(件)","包装方式","备注"}
       
       
        rt.Height = 80  \'设置表格的高度为80毫米
              rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页
        rt.Style.Font = tb.Font
        For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内容
            rt.Cells(0,c).Text = ColNames1(c) \'列名作为标题
            rT.RowS(0).Style.FontSize = 12
            rt.Style.FontSize = 12
            rt.Rows(0).Style.FontBOLD = True
            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 \'开始填入该列内容
                rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
                               
                
            Next
            
        rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never \'禁止被垂直分割
        rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线
        rt.CellStyle.Spacing.All = 0.5 \'单元格内距设为0.5毫米
        rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
        rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头.
        rT.Style.Spacing.Bottom = 0 \'和下面的对象(表格)距离3毫米
       
        doc.Body.Children.Add(rt)

 

 

 

老师以上代码我想在表格最后加一行合计出库存件数要怎么加代码?



--  作者:有点蓝
--  发布时间:2021/7/7 15:26:00
--  
        rT.Style.Spacing.Bottom = 0 \'和下面的对象(表格)距离3毫米
       rt.Cells(rt.rows.count, 0).Text = tb.compute("sum(库存件数)")
        doc.Body.Children.Add(rt)
--  作者:cjl333333333
--  发布时间:2021/7/7 16:07:00
--  
 rt.Cells(rt.rows.count, 0).Text = "合计"
        rt.Cells(rt.rows.count, 5).Text = tb.compute("sum(出库件数)")
        rt.Cells(rt.rows.count, 6).Text = "件"
我这样加老是显示成三行?我想它显示在同一行上就行的。
--  作者:有点蓝
--  发布时间:2021/7/7 16:19:00
--  
dim k as integer = rt.rows.count
rt.Cells(k, 0).Text = "合计"
        rt.Cells(k, 5).Text = tb.compute("sum(出库件数)")
        rt.Cells(k, 6).Text = "件"