Foxtable(狐表)用户栏目专家坐堂 → [求助]专业报表序号


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

主题:[求助]专业报表序号

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


加好友 发短信
等级:小狐 帖子:393 积分:3181 威望:0 精华:0 注册:2019/4/13 16:10:00
[求助]专业报表序号  发帖心情 Post By:2024/4/3 11:04:00 [显示全部帖子]


图片点击可在新窗口打开查看此主题相关图片如下:1212.png
图片点击可在新窗口打开查看


希望实现每一个订单号开始的序号是重新从1开始排的,麻烦老师指导下.

下面是代码:

Dim doc As New PrintDoc
Dim r1 = Tables("打印设置").Current
Dim rt As New Prt.RenderTable
Dim rx As prt.RenderText
Dim cnt As Integer
Dim tbl As Table = Tables("出库单明细表1")
doc.PageSetting.Width = 231 '纸张宽度为100毫米
doc.PageSetting.Height = 298 '纸张高度为120毫米
Doc.PageSetting.LeftMargin = val(r1("左边距")) '设置左边距
Doc.PageSetting.RightMargin = val(r1("右边距")) '设置右边距
Doc.PageSetting.TopMargin = val(r1("上边距")) '设置上边距
Doc.PageSetting.BottomMargin = val(r1("下边距")) '设置下边距

Dim prs As Integer = val(r1("行数"))'每页20行
For p As Integer = 0 To math.Ceiling(tbl.Rows.Count / prs) - 1

Dim CurRow As Row = Tables("出库单").Current
    Dim rt1 As New prt.RenderTable
    rt1 = New prt.RenderTable
    rt1.Style.Spacing.Bottom = 0.2 '和下面的对象(表格)距离3毫米
    rt1.Style.TextAlignVert = prt.AlignVertEnum.center
    rt1.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt1.Width = 200
    rt1.Cols(0).Width = 200
    rt1.Rows.Count = 4 '设置行数
    rt1.Style.Font = New Font("宋体", 20, FontStyle.Bold) '设置字体
    rt1.CellStyle.Spacing.All = 0.5
    rt1.Cells(0, 0).Text = "XXXX有限公司"
    rt1.Cells(1, 0).Style.Font = New Font("宋体", 10) '设置字体
    rt1.Cells(2, 0).Style.Font = New Font("宋体", 10) '设置字体
    rt1.Cells(1, 0).Text = “地址:北京市朝阳区东凤镇京东工业园物流园一路91号”
    rt1.Cells(2, 0).Text = “电话:13788888888 / 134202056888 QQ:488888888”
    rt1.Cells(3, 0).Text = “送 货 单”
    doc.Body.Children.Add(rt1)

    Dim rt2 As New prt.RenderTable
    rt2 = New prt.RenderTable
    rt2.Style.Spacing.Bottom = 0.2 '和下面的对象(表格)距离3毫米
    
    rt2.Style.TextAlignHorz = prt.AlignHorzEnum.left
    rt2.Style.TextAlignVert = prt.AlignVertEnum.center
    'rt2.Cells(0, 0).Style.TextAlignHorz = prt.AlignHorzEnum.left
    rt2.Cells(0, 2).Style.TextAlignHorz = prt.AlignHorzEnum.left
    rt2.Cells(1, 0).Style.TextAlignHorz = prt.AlignHorzEnum.left
    
    rt2.Width = 210
    rt2.Cols(0).Width = 140
    rt2.Cols(1).Width = 70
    
    rt2.Cols.Count = 3
    rt2.Rows.Count = 4 '设置行数
    'rt2.Style.FontSize=11
    rt2.Style.Font = New Font("宋体", 11) '设置字体
    
    rt2.CellStyle.Spacing.All = 0.5
    rt2.Cells(0, 1).Text = "NO: " &Tables("出库单").Current("编号")
    rt2.Cells(1, 0).Text = "客户名称: " &Tables("出库单").Current("客户名称")
    rt2.Cells(1, 1).Text = "项目名称: " &Tables("出库单").Current("项目名称")
    rt2.Cells(2, 0).Text = "联系电话: " &Tables("出库单").Current("联系电话")
    rt2.Cells(2, 1).Text = "电话: " &Tables("出库单").Current("联系电话")
    rt2.Cells(3, 0).Text = "送货地址: " &Tables("出库单").Current("送货地址")
    rt2.Cells(3, 1).Text = "送货单号: " &Tables("出库单").Current("送货单号")
    doc.Body.Children.Add(rt2)

    
Dim drs As List(Of DataRow)
Dim pds As List(Of String) = tbl.DataTable.GetValues("订单编号", tbl.Filter)

rt.Style.GridLines.All = New prt.LineDef(0.1, Color.LightGray)
rt.CellStyle.Spacing.All = 1
rt.Width = 210
rt.Style.FontSize = 10.5 '字体大小为16磅
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
'rt.Rows(0).Style.FontBold = True '字体加粗
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center '内容垂直居中
rt.Rows(0).Style.FontSize = 11 '字体大小为16磅

For c As Integer = 0 To tbl.Cols.Count - 1 '生成列标题
    rt.Cells(0, 0).Text = "序号"
    rt.Cells(0, 1).Text = "名称"
    rt.Cells(0, 2).Text = "规格"
    rt.Cells(0, 3).Text = "数量"
    rt.Cells(0, 4).Text = "面积"
    rt.Cells(0, 5).Text = "单价"
    rt.Cells(0, 6).Text = "金额"
    rt.Cells(0, 7).Text = "加工要求"
    
    rt.Rows(0).Height = 7
    rt.Cols(0).Width = 15
    rt.Cols(1).Width = 45
    rt.Cols(2).Width = 40
    rt.Cols(3).Width = 20
    rt.Cols(4).Width = 20
    rt.Cols(5).Width = 20
    rt.Cols(6).Width = 25
    rt.Cols(7).Width = 40 
Next

For Each pd As String In pds '分产品打印
    If tbl.Filter > "" Then
        drs = tbl.DataTable.Select("订单编号 = '" & pd & "' And " & tbl.Filter)
    Else
        drs = tbl.DataTable.Select("订单编号 = '" & pd & "'")
    End If
    
    
    For Each dr As DataRow In drs '逐行打印此产品的订单
        
        cnt = rt.Rows.Count 
        For r As Integer = p * prs To math.min(rt.Rows.Count - 1, ( p + 1) * prs - 1)
        'For c As Integer = 0 To tbl.Cols.Count - 1
            rt.Cells(cnt, 0).Text = cnt
            rt.Cells(cnt, 1).Text = dr("名称")
            rt.Cells(cnt, 2).Text = dr("规格")
            rt.Cells(cnt, 3).Text = dr("数量")
            rt.Cells(cnt, 4).Text = dr("面积")
            rt.Cells(cnt, 5).Text = dr("单价")
            rt.Cells(cnt, 6).Text = dr("金额")
            rt.Cells(cnt, 7).Text = dr("加工要求")
    Next
    Next
    
    cnt = rt.Rows.Count
    rt.Cells(cnt, 0).Text = "订单号:" & pd & " 小计 " '打印产品的小计
    rt.Rows(cnt).Height = 9
    'rt.Cells(cnt + 1, 0).Text = "订单号:" & pd 
    rt.Cells(cnt, 0).style.TextAlignHorz = prt.AlignHorzEnum.left '水平居中排列
    rt.Cells(cnt, 0).Style.FontSize = 11 '大体大小为16磅
    rt.Cells(cnt, 3).Style.FontSize = 11 '大体大小为16磅
    rt.Cells(cnt, 4).Style.FontSize = 11 '大体大小为16磅
    rt.Cells(cnt, 6).Style.FontSize = 11 '大体大小为16磅
    rt.Cells(cnt, 0).SpanCols = 3 '第5行第2个单元格向右合并3列(用于显示地址)
    rt.Cells(cnt, 3).Text = tbl.compute("Sum(数量)", "订单编号 = '" & pd & "'")
    rt.Cells(cnt, 4).Text = tbl.compute("Sum(面积)", "订单编号 = '" & pd & "'") 
    rt.Cells(cnt, 6).Text = tbl.compute("Sum(金额)", "订单编号 = '" & pd & "'") 
Next
Next
cnt = rt.Rows.Count
rt.Cells(cnt, 0).Text = "合计 " '打印合计
rt.Cells(cnt, 0).Style.Font = New Font("宋体", 11) '设置字体
rt.Cells(cnt, 3).Style.Font = New Font("宋体", 11) '设置字体
rt.Cells(cnt, 4).Style.Font = New Font("宋体", 11) '设置字体
rt.Cells(cnt, 6).Style.Font = New Font("宋体", 11) '设置字体

rt.Cells(cnt, 0).Spancols = 3
rt.Cells(cnt, 3).Text = tbl.compute("Sum(数量)")
rt.Cells(cnt, 4).Text = tbl.compute("Sum(面积)")
rt.Cells(cnt, 6).Text = tbl.compute("Sum(金额)")

rt.Cells(cnt + 1, 0).Text = "加工费用:" & Tables("出库单").Current("加工费用") & "     单价:" & Tables("出库单").Current("加工单价") & "     数量:" & Tables("出库单").Current("加工数量") & "     金额:" & Tables("出库单").Current("加工金额")
rt.Cells(cnt + 1, 0).Spancols = 3
rt.Cells(cnt + 1, 0).Spanrows = 2
rt.Cells(cnt + 1, 0).style.TextAlignHorz = prt.AlignHorzEnum.left

rt.Cells(cnt + 1, 3).Text = "总 金 额:" & tbl.compute("Sum(金额)") '打印合计
rt.Cells(cnt + 1, 3).Style.Font = New Font("宋体", 11) '设置字体
rt.Cells(cnt + 1, 3).Spancols = 5
rt.Cells(cnt + 1, 3).style.TextAlignHorz = prt.AlignHorzEnum.left

rt.Cells(cnt + 2, 3).Text = "大写金额:" & CUMoney(tbl.compute("Sum(金额)")) '打印合计
rt.Cells(cnt + 2, 3).Style.Font = New Font("宋体", 11) '设置字体
rt.Cells(cnt + 2, 3).Spancols = 5
rt.Cells(cnt + 2, 3).Style.GridLines.Top = New Prt.LineDef(0, Color.White)
rt.Cells(cnt + 2, 3).style.TextAlignHorz = prt.AlignHorzEnum.left
doc.Body.Children.Add(rt)

rx = New prt.RenderText
rx.text = "制单员:" & Tables("打印设置").Current("制单员") & "                    制单日期:" & Date.Today() & "                                        客户签字:" & "                                        签收日期:"
rx.Style.FontSize = 9 '大体大小为16磅
rx.Style.TextAlignHorz = prt.AlignHorzEnum.left '水平居中排列
rx.Style.Spacing.top = 2 '和下面的对象(表格)距离3毫米
doc.Body.Children.Add(rx) '加入到报表中
doc.preview()

 回到顶部