各位老师,请教一个问题,下面是导出信息表的代码。如果我只想导出“信息表”中“等级”列为A的全部数据,请问筛选条件应该怎么添加?谢谢
Dim ckl As WinForm.CheckedListBox = e.Form.Controls("CheckedListBox1")
Dim nms As New List(of String)
For i As Integer = 0 To ckl.Items.count - 1 '获取已经勾选的列
If ckl.GetItemChecked(i) Then
nms.Add(ckl.Items(i))
End If
Next
If nms.Count = 0 Then
MessageBox.Show("至少要选择一列","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
'生成Excel表
Dim dt As Table = Tables("信息表")
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
For i As Integer = 0 To nms.count -1
Sheet(0, i).Value = nms(i)
Next
Dim st As XLS.Style = Book.NewStyle '日期列的显示格式
st.Format = "yyyy-MM-dd"
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
For i As Integer = 0 To nms.count -1
Sheet(r + 1, i).Value = dt.rows(r)(nms(i))
If dt.Cols(nms(i)).IsDate Then '如果是日期列
Sheet.Cols(i).Style = st '设置显示格式
End If
Next
Next
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then
Book.Save(dlg.FileName)
Dim Proc As New Process
Proc.File = dlg.FileName
Proc.Start()
End If