以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]用代码移动“合计”  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=12250)

--  作者:易服
--  发布时间:2011/8/27 10:46:00
--  [求助]用代码移动“合计”


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

..............

Dim g As New GroupTableBuilder("分组统计", DataTables("总览"),Filter)
If e.Form.Controls("CheckBox1").Checked Then g.Groups.AddDef("造林年度")
If e.Form.Controls("CheckBox2").Checked Then g.Groups.AddDef("乡名")
If e.Form.Controls("CheckBox3").Checked Then g.Groups.AddDef("村名")
If e.Form.Controls("CheckBox4").Checked Then g.Groups.AddDef("造林树种_主要树种","主要树种")\'添加村名列用于分组
g.Totals.AddDef("小班号",AggregateEnum.Count,"小班个数")
g.Totals.AddDef("设计面积","面积合计") \'添加数量列用于统计
g.VerticalTotal = True \'自动垂直汇总
g.Build()
MainTable = Tables("分组统计")
Tables("分组统计").Sort = "面积合计 DESC" \'降序排列

移动“合计”

If cmc.Value IsNot Nothing or e.Form.Controls("CheckBox3").Checked Then

移动“合计”(如图)

End if
.............


--  作者:hhbb
--  发布时间:2011/8/27 11:06:00
--  

If cmc.Value IsNot Nothing or e.Form.Controls("CheckBox3").Checked Then

 Tables("分组统计").Rows(0)("乡名") =Nothing

 Tables("分组统计").Rows(0)("村名") ="合计"

End if


--  作者:易服
--  发布时间:2011/8/27 12:07:00
--  
以下是引用hhbb在2011-8-27 11:06:00的发言:

If cmc.Value IsNot Nothing or e.Form.Controls("CheckBox3").Checked Then

 Tables("分组统计").Rows(0)("乡名") =Nothing

 Tables("分组统计").Rows(0)("村名") ="合计"

End if

非常感谢!从源头上移动比原来用VBA改变报表“合计”位置,效率提高十多倍。

省去了下列耗时的VBA代码

...............

Dim App As New MSExcel.Application
    Dim Wb As MSExcel.Workbook = App.WorkBooks.Open("D:\\My Documents\\退耕报表\\" & cma.Value  & cmb.Value  & cmc.Value  & cmd.Value  & cme.Value & Name & ".xls")
    Dim Wd As MSExcel.Window = Wb.Windows(1)    \'表示当前工作簿窗口
    Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
    Wd.DisplayZeros = False                 \'不显示0值
    \'  App.Visible = True     \'可见
    If name = "结果分析"  Then
        Wb.Sheets(1).range("A5").Value = "合计"
    End If
    If name = "林种统计" Then
        Wb.Sheets(1).range("A5").Value = "合计"
    End If
    If name = "面积统计" Then
        Wb.Sheets(1).range("A5").Value = "合计"
    End If
    If name = "秋季验收" Then
        Wb.Sheets(1).range("A6").Value = "合计"
    End If
    If name = "补助测算"  Then
        Wb.Sheets(1).range("A7").Value = "合计"
    End If
    If name = "坡度统计" Then
        Wb.Sheets(1).range("A5").Value = "合计"
    End If
    If name = "权属统计" Then
        Wb.Sheets(1).range("A5").Value = "合计"
    End If
    If name = "设计汇总" Then
        Wb.Sheets(1).range("A6").Value = "合计"
    End If
    If name = "设计统计"  Then
        Wb.Sheets(1).range("A7").Value = "合计"
    End If
    If name = "投资测报" Then
        Wb.Sheets(1).range("A7").Value = "合计"
    End If
    If name = "预算汇总" Then
        Wb.Sheets(1).range("A7").Value = "合计"
    End If
    If name = "植被统计" Then
        Wb.Sheets(1).range("A5").Value = "合计"
    End If
    If name = "验收汇总"  Then
        Wb.Sheets(1).range("A6").Value = "合计"
    End If
    If name = "二期补助" Then
        Wb.Sheets(1).range("A7").Value = "合计"
    End If
    Wb.Save
    App.Quit

............