以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  excel报表  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=85507)

--  作者:woshiabc
--  发布时间:2016/5/27 9:50:00
--  excel报表
 请问下,下面代码总是筛选全部数据,怎么修改成按照筛选条件筛选呢?
Dim Book As New XLS.Book(ProjectPath & "Attachments\\报价表.xls") \'打开模板
Dim fl As String = ProjectPath & "Reports\\报价表.xls"

Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Filter As String
With e.Form.Controls("DateTimePicker1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If       
        Filter = Filter & "报价日期 = \'" & .Value & "\'"   
        \'Filter = Filter & "报价日期 = #" & .Value & "#"   \'如果是内部表
 End If
End With
With e.Form.Controls("ComboBox1")
    If .Value IsNot Nothing Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "旺旺QQ = \'" & .Value & "\'"
    End If
End With

If filter > "" Then
    Sheet(1,13).Value = "<" & filter & ">"
Else
    Sheet(1,13).Value = "<all>"
End If
Book.Build() \'生成报表
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
Proc.Start()


--  作者:大红袍
--  发布时间:2016/5/27 10:37:00
--  

1、msgbox(filter)

 

2、你肯定是写错条件的位置了,肯定不是1,13,好好算一个格子

 

3、或者你直接写 Tables("表A").Filter = Filter 也行啊