以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]能不能生成这样的统计表和图表  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=121761)

--  作者:烟斗木木
--  发布时间:2018/7/12 17:25:00
--  [求助]能不能生成这样的统计表和图表
默认表主要由“商品编号、日期、部门”组成,一行对应一笔业务,没有数量金额这些的。
我想生成一个表,能够统计每月各部门的发生的业务数量。进而生成图表(图表我会,就是这个表不知道怎么弄)

--  作者:有点甜
--  发布时间:2018/7/12 19:06:00
--  

你要统计行数?

 

http://www.foxtable.com/webhelp/scr/0158.htm

 


--  作者:烟斗木木
--  发布时间:2018/7/18 11:20:00
--  
想问一下,设计交叉统计的时候,能不能把统计周期设定为上月15日至本月15日
--  作者:有点甜
--  发布时间:2018/7/18 11:59:00
--  
以下是引用烟斗木木在2018/7/18 11:20:00的发言:
想问一下,设计交叉统计的时候,能不能把统计周期设定为上月15日至本月15日

 

参考

 

http://www.foxtable.com/webhelp/scr/2962.htm

 


--  作者:烟斗木木
--  发布时间:2018/7/18 17:40:00
--  
想请您帮忙改一下代码,菜鸡琢磨了一下午还是没弄好。应该是红字部分的问题。
Dim sj As WinForm.DateTimePicker = e.Form.Controls("选择日期")
Dim br As String = sj.value
Dim cmb As WinForm.ComboBox
cmb = Forms("main").Controls("选择项目")
If cmb.SelectedIndex = 0 Then
    Dim d As Date = DataTables("外部保洁").Compute("日期时间 = \'br\'", "保洁地点 = \'" & _UserGroup & "\'")
    Dim tmp As String = ProjectPath & "Attachments\\每日报表wb.xls"
    Dim rpt As String = ProjectPath & "Reports\\" & d.Year & "-" &  d.Month & "-" &  d.day & _UserGroup & "-外保报表.xls"
    Dim Book As New XLS.Book(tmp)
    Book.Build()
    Book.Save(rpt)
end if




--  作者:有点甜
--  发布时间:2018/7/18 18:05:00
--  

参考代码

 

Dim sj As WinForm.DateTimePicker = e.Form.Controls("选择日期")
Dim d As Date = sj.value

Tables("外部保洁").filter = "日期时间 = \'" & d & "\' and 保洁地点 = \'" & _UserGroup & "\'"
Dim tmp As String = ProjectPath & "Attachments\\每日报表wb.xls"
Dim rpt As String = ProjectPath & "Reports\\" & d.Year & "-" &  d.Month & "-" &  d.day & _UserGroup & "-外保报表.xls"
Dim Book As New XLS.Book(tmp)
Book.Build()
Book.Save(rpt)


--  作者:烟斗木木
--  发布时间:2018/7/19 9:52:00
--  
老师,两个问题:
1.怎么自己选择保存的路径呢,默认都保存到reports里了。
2.把上述代码做成按钮后,需要先点一下窗口内的表格,然后再点保存才行,不然报表内没有内容。PS:我用的是动态绑定表的方法。

--  作者:有点甜
--  发布时间:2018/7/19 10:22:00
--  

2、你选中日期了没有?表格筛选了没有?你的模板是如何设计的?模板发上来看看

 

1、

 


Dim sj As WinForm.DateTimePicker = e.Form.Controls("选择日期")
Dim d As Date = sj.value

Dim dlg As new SaveFileDialog
dlg.Filter = "excel|*.xls;*.xlsx"
dlg.InitialDirectory = "d:\\"
dlg.FileName = d.Year & "-" &  d.Month & "-" &  d.day & _UserGroup & "-外保报表.xls"
If dlg.ShowDialog = DialogResult.OK Then
    Tables("外部保洁").filter = "日期时间 = \'" & d & "\' and 保洁地点 = \'" & _UserGroup & "\'"
    Dim tmp As String = ProjectPath & "Attachments\\每日报表wb.xls"
    Dim rpt As String = dlg.FileName
    Dim Book As New XLS.Book(tmp)
    Book.Build()
    Book.Save(rpt)
End If


--  作者:烟斗木木
--  发布时间:2018/7/19 10:48:00
--  
检查了一下,果然是模板的问题,谢谢老师图片点击可在新窗口打开查看
--  作者:烟斗木木
--  发布时间:2018/7/24 8:57:00
--  
这段交叉统计的代码中,能不能加入计算?
目前能够统计数量(行数)并生成对应的年、月统计表,但现在每个月结束的时候还要扣除一些数量。因为统计的是行数,没有数据列可用,不知道要怎么设计才能实现最终的统计结果,请老师指点一下(基于窗口)。

Dim bd1 As New CrossTableBuilder("统计表1", DataTables("外保全年统计"))
Dim dt1 As fxDataSource
bd1.HGroups.AddDef("保洁地点")
bd1.VGroups.AddDef("日期时间", DateGroupEnum.Year, "{0}年")
bd1.VGroups.AddDef("日期时间", "{0}月")
bd1.Totals.AddDef("日期时间", AggregateEnum.Count, "日期时间")
dt1 = bd1.BuildDataSource()
Tables("main_Table8").DataSource = dt1