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


  共有2204人关注过本帖平板打印复制链接

主题:专业报表问题

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


加好友 发短信
等级:八尾狐 帖子:1911 积分:17032 威望:0 精华:0 注册:2014/7/29 19:09:00
专业报表问题  发帖心情 Post By:2016/4/11 18:32:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:双表数据并排.png
图片点击可在新窗口打开查看

如上图,生产单的明细表有两个一个是物料明细,一个是工序明细,打印时要求在一行中左边显示物料明细的内容,右边显示工序明细的内容

当只有一个明细表是觉得很简单:用下面的代码就可以
‘----------------------------------------
rt = New prt.RenderTable() '定义一个表格对象

rt.Rows(rt.Rows.Count).Height = 9  '新增一行
rt.Cells(rt.Rows.Count-1,0).SpanCols = 2
rt.Cells(rt.Rows.Count-1,0).Text = "产品代号"
rt.Cells(rt.Rows.Count-1,1).SpanCols = 3
rt.Cells(rt.Rows.Count-1,1).Text = CurRow("产品编码")
rt.Cells(rt.Rows.Count-1,2).Text = "产品规格"
rt.Cells(rt.Rows.Count-1,3).Text = CurRow("规格")
rt.Cells(rt.Rows.Count-1,4).SpanCols = 2
rt.Cells(rt.Rows.Count-1,4).Text = "下单日期"
rt.Cells(rt.Rows.Count-1,5).SpanCols = 2
rt.Cells(rt.Rows.Count-1,5).Text = CurRow("下单日期")

rt.Rows(rt.Rows.Count).Height = 9  '新增一行
rt.Cells(rt.Rows.Count-1,0).SpanCols = 2
rt.Cells(rt.Rows.Count-1,0).Text = "产品名称"
rt.Cells(rt.Rows.Count-1,1).SpanCols = 3
rt.Cells(rt.Rows.Count-1,1).Text = CurRow("品名")
rt.Cells(rt.Rows.Count-1,2).Text = "生产数量"
rt.Cells(rt.Rows.Count-1,3).Text = CurRow("生产数量")
rt.Cells(rt.Rows.Count-1,4).SpanCols = 2
rt.Cells(rt.Rows.Count-1,4).Text = "完成日期"
rt.Cells(rt.Rows.Count-1,5).SpanCols = 2
rt.Cells(rt.Rows.Count-1,5).Text = CurRow("计划结束")

rt.Rows(rt.Rows.Count).Height = 9  '新增一行
rt.Cells(rt.Rows.Count-1,0).SpanCols = 6
rt.Cells(rt.Rows.Count-1,0).Text = "物料明细"
rt.Cells(rt.Rows.Count-1,1).SpanCols = 6
rt.Cells(rt.Rows.Count-1,1).Text = "工序明细"

rt.Rows(rt.Rows.Count).Height = "auto"  '新增一行
rt.Rows(rt.Rows.Count-1).Style.Font = New Font("宋体",9) '设置字体
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
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.Page  '指定表头行

Dim ColNames As String() = {"使用工序","物料编码","规格","计量单位","需求数量","工序号","工序名称","模号","机台吨位","加工方式","生产车间"} '明细表数据列
Dim drs As List(Of DataRow)
drs = DataTables("生产单_物料明细").Select("生产单号 = '" & CurRow("生产单号") & "'")
If drs.Count > 0 Then  '如果有值
    For i As Integer = 0 To drs.Count-1
        rt.Rows(rt.Rows.Count).Height = rh '新增一行
        For c As Integer = 0 To ColNames.Length -1
            If c < 5 Then  '左边五列来自生产物料明细
                rt.cells(rt.Rows.Count-1,c).text = dr(i)(ColNames(c))
            Else
                rt.cells(rt.Rows.Count-1,c).text = dr(i)(ColNames(c))
            End If
        Next
    Next
End If
'----------------------------------------------------------3

上面红色部份不知道怎么写了,因为两个明细表的行数可能不一样,比如,只有2个工序,但可能用到4种物料;是否必须按多行的那个行数来计算?
前五列是从物料明细取数,后五列又是从工序明细取数,要怎么写代码?

谢谢!



 回到顶部