Foxtable(狐表)用户栏目专家坐堂 → 录入表自动生成汇总表?解决我一年的工作量。


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

主题:录入表自动生成汇总表?解决我一年的工作量。

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


加好友 发短信
等级:狐神 帖子:4752 积分:34568 威望:0 精华:0 注册:2008/8/31 22:44:00
  发帖心情 Post By:2019/8/4 10:18:00 [显示全部帖子]

找不到更好的方法,试试笨方法:

增加一个“年月”的表达式列,表达式为:SubString(Convert([日期],'System.String'),1,4) + '年' +
SubString(Convert([日期],'System.String'),6,IIF(SubString(Convert([日期],'System.String'),7,1) In ('-','/'),1,2)) + '月'

Dim dic As New Dictionary(Of String, String)


For Each dr As DataRow In DataTables("表A").DataRows
    Dim bds As String = dr("年月") &  "_" & dr("业务类型") & "," & dr("执行员工")
    bds += "/" & dr("年月") &  "_业务量." & dr("业务类型") & "," & dr("业务量")
    Dim key As String = dr("客户名称")
    If dic.ContainsKey(key)
        dic(key) += "/" & bds
    Else
        dic.Add(key,bds)
    End If
Next

Dim bm As String = "汇总"

Dim dtb As New DataTableBuilder(bm)

dtb.AddDef("客户名称", Gettype(String), 32)

For Each s As String In dic("虹桥公司").split("/")
    If s.Contains(".")
        dtb.AddDef(s.split(",")(0), Gettype(Integer), 32)

    Else
        dtb.AddDef(s.split(",")(0),Gettype(String), 32)
    End If
Next
dtb.Build()

For Each k As String In dic.Keys

    Dim dr As DataRow = DataTables(bm).AddNew
    dr("客户名称") = k
    For Each s As String In dic(k).split("/")
        dr(s.split(",")(0)) = s.split(",")(1)
    Next
Next
For Each dc As DataCol In DataTables(bm).DataCols
    If dc.Name.Contains("业务量.")
        dc.Caption = dc.Name.split(".")(0)
    End If
Next
DataTables(bm).BuildHeader
Tables(bm).ListMode = True
Tables(bm).AutoSizeCols
MainTable= Tables(bm)

 

[此贴子已经被作者于2019/8/4 17:03:24编辑过]

 回到顶部