Foxtable(狐表)用户栏目专家坐堂 → [求助]交叉统计日期分组漏日期


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

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

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


加好友 发短信
等级:幼狐 帖子:113 积分:731 威望:0 精华:1 注册:2011/8/16 14:13:00
  发帖心情 Post By:2011/8/24 12:04:00 [显示全部帖子]

紙上不談兵,用實例說話!

 回到顶部
帅哥哟,离线,有人找我吗?
紙上不談兵
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:113 积分:731 威望:0 精华:1 注册:2011/8/16 14:13:00
  发帖心情 Post By:2011/8/24 13:48:00 [显示全部帖子]

上傳文件,給你搞定!

 回到顶部
帅哥哟,离线,有人找我吗?
紙上不談兵
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:113 积分:731 威望:0 精华:1 注册:2011/8/16 14:13:00
  发帖心情 Post By:2011/8/25 17:37:00 [显示全部帖子]

完善一下:判断(29-31日)是否可见

Dim Filter,fl,fl1 As String
Dim Y,M,Days As Integer

Filter = "[姓名]<>''"
Y= e.Form.Controls("TextBox1").Value
M = e.Form.Controls("TextBox2").Value
Days = Date.DaysInMonth(Y,M)

Dim SD As Date = New Date(Y,M,1)
Dim ED As Date = New Date(Y,M,Days)
Filter = Filter & "And [日期] >= #" & SD & "# And [日期]<= #" & ED & "#"

Dim Ts As String() = {"","C","G","小线","开后","小后","佳洁云"}
For n As Integer = 1 To 6
    If e.Form.Controls("CheckBox"  & n).Checked = False Then
        Filter = Filter & " And [部门] <> '" & Ts(n) & "'"
    End If
Next

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 t As Table = Tables("计件工资")
fl  = ProjectPath & "Attachments\计件工资模板.xls"
fl1  = ProjectPath & "Reports\计件工资" & Y & "-" & M & ".xls"

Dim Book As New XLS.Book(fl)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
For Y = 3 To 33
    sheet(2,Y).value = ""
Next

For Y = 3 To 33
    For M = 2 To  t.cols.count-1
        If sheet(1,Y).value = t.cols(M).Caption Then
            sheet(2,Y).value = "[" & t.cols(M).name & "]"
        End If
    Next
    if  Y > 30 Then
         Sheet.Cols(Y).Visible = Y-2<= Days
    End if
Next

Book.Save(fl)
Book.Build() '生成细节区
Book.Save(fl1) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = fl1
Proc.Start()
e.form.close()
[此贴子已经被作者于2011-8-25 17:53:13编辑过]

 回到顶部