Dim Filter As String
With RibbonTabs("运单管理").Groups("运单管理").Items("上游客户")
If .text > "" Then
Filter = "上游客户 like '%" & .text & "%'"
End If
End With
With RibbonTabs("运单管理").Groups("运单管理").Items("品牌")
If .text > "" Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "品牌 like '%" & .text & "%'"
End If
End With
With RibbonTabs("运单管理").Groups("运单管理").Items("上游动态")
If .text > "" Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "上游动态 like '%" & .text & "%'"
End If
End With
With RibbonTabs("运单管理").Groups("运单管理").Items("运输单号")
If .text > "" Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "运输单号 like '%" & .text & "%'"
End If
End With
Dim cmd As New SQLCommand
cmd.C
Dim nms() As String = {"部门", "上游客户", "品牌", "商品车", "运输单号", "VIN码"}
If Filter > "" Then
cmd.CommandText = "Sel ect 部门,上游客户,品牌,商品车,运输单号,VIN码 F rom {运单管理} Where '" & Filter & "' "
Else
cmd.CommandText = "Sel ect 部门, 上游客户, 品牌, 商品车, 运输单号, VIN码 F rom {运单管理} "
End If
Dim dt As DataTable = cmd.ExecuteReader()
Dim Book As New XLS.Book
Dim fl As String = "c:\reports\test.xlsx"
Book.Save(fl)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Style As Xls.Style = Book.NewStyle
Style.BackColor = Color.Red
For c As Integer = 0 To nms.Count - 1
Sheet(0, c).Value = nms(c)
Next
For r As Integer = 0 To dt.DataRows.Count - 1
For c As Integer = 0 To nms.Count - 1
Sheet(r + 1, c).Value = dt.DataRows(r)(nms(c))
Next
Next
'打开工作簿
Book = New XLS.Book(fl)
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
Proc.Start()