Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共30 条记录, 每页显示 10 条, 页签: [1] [2][3]
[浏览完整版]

标题:[求助]交叉统计日期分组漏日期

1楼
zhangqinyun 发表于:2011/8/24 12:02:00

如统计工资表:

         01日  02日  04日  05日  。。。

张三      30     40    30     20

李四      20     30    50     40

 

03日由于休息没工资,统计的时候03日就没了。

虽然标题上有日期,但是对应的列名确是

01日 金额_1

02日 金额_2

04日 金额_3

05日 金额_4

于是我统计后放入模板上就变成了。

 

         01日  02日  03日  04日  。。。

张三      30     40    30     20

李四      20     30    50     40

 

怎么办啊

2楼
紙上不談兵 发表于:2011/8/24 12:04:00
紙上不談兵,用實例說話!
3楼
狐狸爸爸 发表于:2011/8/24 12:05:00
生成之后,在用代码从统计表删除这些没有用的日期列
[此贴子已经被作者于2011-8-24 12:04:39编辑过]
4楼
qhczy 发表于:2011/8/24 12:31:00
03日的,可以用0填充,或删除03日.
5楼
zhangqinyun 发表于:2011/8/24 12:47:00

不是啊!

我需要的报表是这样的:

         01日  02日  03日  04日  05日  。。。

张三      30     40              30     20

李四      20     30              50     40

 

但是现在确是:

         01日  02日  03日  04日  。。。

张三      30     40    30     20

李四      20     30    50     40

 

 

我的代码:

Dim Filter As String = "[姓名]<>''"
Dim Y As Integer = Forms("选择月份").Controls("TextBox1").Value
Dim M As Integer = Forms("选择月份").Controls("TextBox2").Value
Dim SD As Date = New Date(Y,M,1)
Dim Days As Integer = Date.DaysInMonth(Y,M)
Dim ED As Date = New Date(Y,M,Days)
Filter = Filter & "And [日期] >= #" & SD & "# And [日期]<= #" & ED & "#"
If Forms("选择月份").Controls("CheckBox1").Checked = False Then
    Filter = Filter & "And [部门]<>'C'"
End If
If Forms("选择月份").Controls("CheckBox2").Checked = False Then
    Filter = Filter & "And [部门]<>'G'"
End If
If Forms("选择月份").Controls("CheckBox3").Checked = False Then
    Filter = Filter & "And [部门]<>'I'"
End If
If Forms("选择月份").Controls("CheckBox4").Checked = False Then
    Filter = Filter & "And [部门]<>'开后'"
End If
If Forms("选择月份").Controls("CheckBox5").Checked = False Then
    Filter = Filter & "And [部门]<>'小后'"
End If
If Forms("选择月份").Controls("CheckBox6").Checked = False Then
    Filter = Filter & "And [部门]<>'观澜'"
End If
If Forms("选择月份").Controls("CheckBox7").Checked = False Then
    Filter = Filter & "And [部门]<>'机器房'"
End If
Dim g As New CrossTableBuilder("计件工资", DataTables("计件表"), Filter)
g.HGroups.AddDef("部门")
g.HGroups.AddDef("姓名")
g.VGroups.AddDef("日期", DateGroupEnum.Day, "{0}日")
g.Totals.AddDef("金额", "金额")
g.HorizontalTotal = True
g.VerticalTotal = True
g.Decimals = 1
g.Build()
Dim Book As New XLS.Book(ProjectPath & "Attachments\计件工资模板.xls")
Dim fl As String = ProjectPath & "Reports\计件工资" & Y & "-" & M & ".xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = fl
Proc.Start()

6楼
紙上不談兵 发表于:2011/8/24 13:48:00
上傳文件,給你搞定!
7楼
zhangqinyun 发表于:2011/8/24 14:44:00

我细说一下

我需要的报表是这样的(Excel)

         01日  02日  03日  04日  05日  。。。

张三      30     40              30     20

李四      20     30              50     40

 

但是现在确是:

         01日  02日  03日  04日  。。。

张三      30     40    30     20

李四      20     30    50     40

 

在员工计件里面的月末基本工资统计

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:hxx_0824.zip

8楼
狐狸爸爸 发表于:2011/8/24 15:08:00

代码在哪个表的那个窗口?你说的员工计件表和月末基本工资统计窗口,我没找到

 

9楼
zhangqinyun 发表于:2011/8/24 15:26:00
导航进去
10楼
狐狸爸爸 发表于:2011/8/24 15:49:00
Dim Filter As String = "[姓名]<>''"
Dim Y As Integer = Forms("选择月份").Controls("TextBox1").Value
Dim M As Integer = Forms("选择月份").Controls("TextBox2").Value
Dim SD As Date = New Date(Y,M,1)
Dim Days As Integer = Date.DaysInMonth(Y,M)
Dim ED As Date = New Date(Y,M,Days)
Filter = Filter & "And [日期] >= #" & SD & "# And [日期]<= #" & ED & "#"
If Forms("选择月份").Controls("CheckBox1").Checked = False Then
    Filter = Filter & "And [部门]<>'C'"
End If
If Forms("选择月份").Controls("CheckBox2").Checked = False Then
    Filter = Filter & "And [部门]<>'G'"
End If
If Forms("选择月份").Controls("CheckBox3").Checked = False Then
    Filter = Filter & "And [部门]<>'小线'"
End If
If Forms("选择月份").Controls("CheckBox4").Checked = False Then
    Filter = Filter & "And [部门]<>'开后'"
End If
If Forms("选择月份").Controls("CheckBox5").Checked = False Then
    Filter = Filter & "And [部门]<>'小后'"
End If
If Forms("选择月份").Controls("CheckBox6").Checked = False Then
    Filter = Filter & "And [部门]<>'佳洁云'"
End If
Dim g As New CrossTableBuilder("计件工资", DataTables("计件表"), Filter)
g.HGroups.AddDef("部门")
g.HGroups.AddDef("姓名")
g.VGroups.AddDef("日期", DateGroupEnum.Day, "{0}日")
g.Totals.AddDef("金额", "金额")
g.HorizontalTotal = True
g.VerticalTotal = True
g.Decimals = 1
g.Build()
Dim Book As New XLS.Book(ProjectPath & "Attachments\计件工资模板.xls")
Dim fl As String = ProjectPath & "Reports\计件工资" & Y & "-" & M & ".xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Book.Build() '生成细节区
Sheet = Book.Sheets(0)
For i As Integer = sheet.Cols.Count - 1 To 0 Step -1
    Dim nm As String = sheet(1,i).text
    If nm.EndsWith("日")
        If Tables("计件工资").Cols.Contains("金额_" & val(nm)) = False Then
            Sheet.Cols.RemoveAt(i)
        End If
    End If
Next
Book.Save(fl) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = fl
Proc.Start()
Forms("选择月份").Close
共30 条记录, 每页显示 10 条, 页签: [1] [2][3]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03125 s, 3 queries.