以文本方式查看主题

-  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=28213)

--  作者:hrc11
--  发布时间:2013/1/22 16:06:00
--  EXCEL报表求助
条件生成EXCEL报表,请大家帮帮忙。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目7.rar


--  作者:lin_hailun
--  发布时间:2013/1/22 16:29:00
--  
 楼主,你的代码就差一步了。测试有效。

If e.Form.Controls("DateTimePicker1").VALUE Is Nothing = False Then
    Dim Filter As String = "<[日期] = #" & e.Form.Controls("DateTimePicker1").VALUE  & "#"
    Dim ra1 As WinForm.RadioButton = e.Form.Controls("RadioButton1")
    Dim ra2 As WinForm.RadioButton = e.Form.Controls("RadioButton2")
    Dim cb As WinForm.CheckedComboBox = e.Form.Controls("CheckedComboBox1")
    Dim Filter1 As String
    If ra2.Checked = True Then
        If cb.Value>"" Then
            Dim nms() As String = cb.Value.Split(",")
            For i As Integer = 0 To nms.Length - 1
                filter1 &= " [客户] = \'" & nms(i) & "\' or "
            Next
            filter1 &= "1=2"
            filter &= " And (" & filter1 & ")"
        Else
            MessageBox.show("兄弟,你还没选择要复制订单的客户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            cb.Select()
            Return
        End If
    End If
   
    Dim Book As New XLS.Book(ProjectPath & "Attachments\\送货单.xls") \'打开模板
    Dim fl As String = ProjectPath & "Reports\\送货单.xls"
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    filter &=  ">"
    msgbox(filter)
    Sheet(1,12).Value = filter
   
    Book.Build() \'生成报表
    Book.Save(fl)
    Dim Proc As New Process
    Proc.File = fl
    Proc.Start()
Else
    MessageBox.Show("你忘记选择要复制的订单日期了哦!","^O^^O^温馨提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    e.Form.Controls("DateTimePicker1").Select()
    Return
End If
e.Form.Close
[此贴子已经被作者于2013-1-22 16:29:12编辑过]

--  作者:hrc11
--  发布时间:2013/1/22 17:57:00
--  
搞定,多谢林生指导!