我是这样的结构,现①筛选,②再汇总。试了一下1天的数据,导出来还是全月的。不行啊,是不是结构不行,还是代码有问题啊①的代码:Dim gx As WinForm.ComboBox = e.Form.Controls("工序")
Dim jt As WinForm.combobox = e.Form.Controls("机台")
Dim xh As WinForm.combobox = e.Form.Controls("型号")
Dim gh As WinForm.combobox = e.Form.Controls("工号")
Dim glhm As WinForm.combobox = e.Form.Controls("管理号码")
Dim filter As String = "1=1"
If gx.Text > "" Then
filter &= " and 工程 = '" & gx.Text & "'"
End If
If jt.Text > "" Then
filter &= " and 机台号码 = '" & jt.Text & "'"
End If
If xh.Text > "" Then
filter &= " and 型号 = '" & xh.Text & "'"
End If
If gh.Text > "" Then
filter &= " and 工号 = '" & gh.Text & "'"
End If
If glhm.Text > "" Then
filter &= " and 管理号码 = '" & glhm.Text & "'"
End If
With e.Form.Controls("开始时间")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "作业日期>= #" & .Value & "#"
End If
End With
With e.Form.Controls("结束时间")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "作业日期<= #" & .Value & "#"
End If
End With
Tables("加硫").Filter = filter
②的代码:Dim g As New GroupTableBuilder("统计表1", DataTables("加硫"))
g.Groups.AddDef("型号")
g.Totals.AddDef("生产数")
g.Totals.AddDef("实际成型回数")
g.Totals.AddDef("标准成型回数")
g.VerticalTotal = True
g.Build()
Dim t As Table = Tables("统计表1")
Dim dc = t.DataTable.DataCols.Add("缺损率", Gettype(Double), "(实际成型回数-标准成型回数)/标准成型回数")
dc.SetFormat("0.00%")
MainTable = Tables("统计表1")
If MessageBox.Show("确定要生成所选数据的模具缺损率吗?","确认",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes Then
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Tables("统计表1").SaveExcel(dlg.FileName, "模具缺损率") '保存文件
End If
messagebox.show("生成成功!","确认")
DataTables.Unload("统计表1")
Else
e.Form.controls("Button2").Select
End If

此主题相关图片如下:无标题.jpg
