源代码是这样的,但是查询的是所有数据的行,各位大侠指教。
Dim gx As WinForm.ComboBox = e.Form.Controls("工序")
Dim filter As String = "1=1"
If gx.Text > "" Then
filter &= " and 工程 = '" & gx.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 pr As Integer = DataTables("检查").DataRows.Count '查询表行数
Dim Book As New XLS.Book(ProjectPath & "Attachments\报表1.xls")
Dim fl As String = ProjectPath & "Reports\报表1.xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(3,9).Value = "<" & Tables("检查").Filter & ">" '写入打印条件
Book.Build() '生成细节区
Book.Save(fl) '保存工作簿
If MessageBox.Show("成功导入数据"& pr &"条,是否打开数据?","确认",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) =DialogResult.OK Then
Dim Proc As New Process
Proc.File = fl
Proc.Start()
Else
Syscmd.Table.ToggleSortAndFilter()
e.Form().Close
End If