DataTables("临时版本跟踪表").LoadFilter = ""
DataTables("临时版本跟踪表").Load
Dim kh As WinForm.ComboBox = e.Form.Controls("客户")
Dim bdjx As WinForm.ComboBox = e.Form.Controls("博达机型")
Dim xqbh As WinForm.TextBox = e.Form.Controls("需求编号")
Dim xqms As WinForm.TextBox = e.Form.Controls("需求描述")
Dim qssj As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker3")
Dim jzsj As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker4")
'If xqbh.text = "请输入需求编号" Then
' DataTables("临时版本跟踪表").LoadFilter = "客户 like '%" & kh.text & "%' and 博达机型 like '%" & bdjx.text & "%'"
' DataTables("临时版本跟踪表").Load
'Else
' DataTables("临时版本跟踪表").LoadFilter = "客户 like '%" & kh.text & "%' and 博达机型 like '%" & bdjx.text & "%' and [需求编号] like '%" & xqbh.text & "%'"
' DataTables("临时版本跟踪表").Load
'End If
If qssj.text = "" AndAlso jzsj.text = "" Then
If xqms.text = "请输入字符串模糊匹配" Then
DataTables("临时版本跟踪表").LoadFilter = "客户 like '%" & kh.text & "%' and 博达机型 like '%" & bdjx.text & "%'"
DataTables("临时版本跟踪表").Load
Else
DataTables("临时版本跟踪表").LoadFilter = "客户 like '%" & kh.text & "%' and 博达机型 like '%" & bdjx.text & "%' and [需求描述] like '%" & xqms.text & "%'"
DataTables("临时版本跟踪表").Load
End If
Else
If xqms.text = "请输入字符串模糊匹配" Then
DataTables("临时版本跟踪表").LoadFilter = "客户 like '%" & kh.text & "%' and 博达机型 like '%" & bdjx.text & "%' and 需求提交时间 > '" & qssj.Value & "' and 需求提交时间 < '" & jzsj.Value.adddays(1) & "'"
DataTables("临时版本跟踪表").Load
Else
DataTables("临时版本跟踪表").LoadFilter = "客户 Like '%" & kh.text & "%' and 博达机型 like '%" & bdjx.text & "%' and [需求描述] like '%" & xqms.text & "%' and 需求提交时间 > '" & qssj.Value & "' and 需求提交时间 < '" & jzsj.Value.adddays(1) & "'"
DataTables("临时版本跟踪表").Load
End If
End If
Dim dt As Table = Tables("临时版本跟踪表")
Dim filepath As String = "C:\临时版本跟踪表\" & "查询导出" & ".xls"
Dim nms() As String = {"临时版本编号", "需求编号", "博达机型", "客户", "需求提交时间", "预计提供时间", "开发环境", "代码message", "软件环境", "show_version", "技术支持邮箱", "研发邮箱", "客户期望交期", "log", "发布目录", "测试目录", "状态", "状态直白", "需求描述"} '要导出的列名
Dim caps() As String = {"临时版本编号", "需求编号", "博达机型", "客户", "需求提交时间", "预计提供时间", "开发环境", "代码message", "软件环境", "show_version", "技术支持邮箱", "研发邮箱", "客户期望交期", "log", "发布目录", "测试目录", "状态", "状态直白", "需求描述"} '对应的列标题
Dim szs() As Integer = {100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 80, 200, 300} '对应的列宽
Dim Book As New XLS.Book '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Dim st As XLS.Style = Book.NewStyle '日期列的显示格式
st.Format = "yyyy-MM-dd hh:mm:ss"
For c As Integer = 0 To nms.length - 1
Sheet(0, c).Value = caps(c) '指定列标题
Sheet.Cols(c).Width = szs(c) '指定列宽
If dt.Cols(nms(c)).IsDate Then '如果是日期列
Sheet.Cols(c).Style = st '设置显示格式
End If
Next
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
For c As Integer = 0 To nms.length - 1
If Not dt.rows(r).Isnull(nms(c)) Then Sheet(r + 1, c).Value = dt.rows(r)(nms(c))
Next
Next
Book.Save(filepath)-----’实际数据分好几页呢,可是导出后只有第一页数据。
MessageBox.show("保存路径:" & FilePath, "导出成功", MessageBoxButtons.OK, MessageBoxIcon.Information)
DataTables("临时版本跟踪表").Load
With DataTables("临时版本跟踪表")
.LoadOver = "需求编号"
.LoadReverse = True
.LoadTop = 27
.LoadPage = 0
.Load()
If .TotalPages = 0 Then
.LoadPage = 0
e.Form.Controls("TextBox1").Value = .LoadPage & "/" & .TotalPages
Else
e.Form.Controls("TextBox1").Value = .LoadPage + 1 & "/" & .TotalPages
End If
End With