以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  帮我看看,这个到底错在那里呀  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=88347)

--  作者:hongyefor
--  发布时间:2016/8/1 12:38:00
--  帮我看看,这个到底错在那里呀

Dim r As Row = Tables("开票主表").Current
Dim Book As New XLS.Book(ProjectPath & "Attachments\\开票汇总清单.xls") \'打开模板
Dim fl As String = "d:/开票信息/"+(r("客户名称"))+(r("所属年份")) + (r("所属月份"))   +"开票汇总清单.xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(1,1).Value = "<[@企业信息,企业名称,0]& [@开票主表,年,0]&"年"& [@开票主表,月,0]&"月"& [@开票主表,客户名称,0] &"开票汇总"> "
Book.Build() \'生成报表
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
Proc.Verb = "Print" \'指定动作
Proc.Start()

 

到红色这里错误


--  作者:大红袍
--  发布时间:2016/8/1 14:33:00
--  

 

Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年"" & [@开票主表,月,0] & ""月"" & [@开票主表,客户名称,0] & ""开票汇总""> "


--  作者:hongyefor
--  发布时间:2016/8/1 16:10:00
--  


图片点击可在新窗口打开查看此主题相关图片如下:cw.jpg
图片点击可在新窗口打开查看

 


Dim r As Row = Tables("开票主表").Current
Dim Book As New XLS.Book(ProjectPath & "Attachments\\开票汇总清单.xls") \'打开模板
Dim fl As String = "d:/开票信息/"+(r("客户名称"))+(r("年")) +"年"+ (r("月"))   +"月 开票汇总清单.xls"
If FileSys.FileExists("fl") Then \'如果指定的文件存在
    FileSys.DeleteFile("fl",2,2) \'则彻底删除之
End If
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(1,1).Value = Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年"" & [@开票主表,月,0] & ""月"" & [@开票主表,客户名称,0] & ""开票汇总""> "
Book.Build() \'生成报表
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
Proc.Start()

还是有错误啊


--  作者:hongyefor
--  发布时间:2016/8/1 17:01:00
--  
呵呵,多写了一句话
--  作者:hongyefor
--  发布时间:2016/8/1 17:34:00
--  

Dim r As Row = Tables("开票主表").Current
Dim Book As New XLS.Book(ProjectPath & "Attachments\\开票汇总清单.xls") \'打开模板
Dim fl As String = "d:/开票信息/"+(r("客户名称"))+(r("年")) + (r("月"))   +"开票汇总清单.xls"
If FileSys.FileExists("d:/开票信息/"+(r("客户名称"))+(r("年")) + (r("月"))   +"开票汇总清单.xls") Then \'如果指定的文件存在
    FileSys.DeleteFile("d:/开票信息/"+(r("客户名称"))+(r("年")) + (r("月"))   +"开票汇总清单.xls",2,2) \'则彻底删除之
End If
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年"" & [@开票主表,月,0] & ""月"" & [@开票主表,客户名称,0] & ""开票汇总""> "
Book.Build() \'生成报表
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
Proc.Verb = "Print" \'指定动作
Proc.Start()

 

如何增加一个,预览和打印设置代码呢?

 


--  作者:hongyefor
--  发布时间:2016/8/1 18:24:00
--  

Dim cj As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim dm As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim hm As WinForm.ComboBox = e.Form.Controls("ComboBox3")
Dim kpn As WinForm.ComboBox = e.Form.Controls("ComboBox4")
Dim kpy As WinForm.ComboBox = e.Form.Controls("ComboBox5")
Dim r As Row = Tables("开票主表").Current
Dim Book As New XLS.Book(ProjectPath & "Attachments\\开票汇总清单.xls") \'打开模板
If cj.text  > "" Then
    If kpn.text  > "" Then
        If kpy.text  > "" Then
            Dim fl As String ="d:/开票信息/"+ (r("年"))  +"年" + (r("月"))   +"月" +(r("客户名称"))+"开票汇总清单.xls"
        Else
            Dim fl As String ="d:/开票信息/"+ (r("年"))  +"年" +(r("客户名称"))+"开票汇总清单.xls"
        End If
    Else
        If kpy.text  > "" Then
            Dim fl As String ="d:/开票信息/"+ (r("月"))   +"月" +(r("客户名称"))+"开票汇总清单.xls"
        Else
            Dim fl As String ="d:/开票信息/"+ (r("客户名称"))+"开票汇总清单.xls"
        End If
    End If
Else
    If kpn.text  > "" Then
        If kpy.text  > "" Then
            Dim fl As String ="d:/开票信息/"+ (r("年"))  +"年" + (r("月"))   +"月 开票汇总清单.xls"
        Else
            Dim fl As String ="d:/开票信息/"+ (r("年"))  + "年 开票汇总""> "
        End If
    Else
        If kpy.text  > "" Then
            Dim fl As String ="d:/开票信息/"+ (r("月"))   +"月 开票汇总清单.xls"
        Else
            Dim fl As String ="d:/开票信息/" + "开票汇总清单.xls"
        End If
    End If
End If

If FileSys.FileExists("fl") Then \'如果指定的文件存在
    FileSys.DeleteFile("fl",2,2) \'则彻底删除之
End If
Dim Sheet As XLS.Sheet = Book.Sheets(0)
If cj.text  > "" Then
    If kpn.text  > "" Then
        If kpy.text  > "" Then
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年"" & [@开票主表,月,0] & ""月"" & [@开票主表,客户名称,0] & ""开票汇总""> "
        Else
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年"" & [@开票主表,客户名称,0] & ""开票汇总""> "
        End If
    Else
        If kpy.text  > "" Then
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,月,0] & ""月"" & [@开票主表,客户名称,0] & ""开票汇总""> "
        Else
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & ""  "" & [@开票主表,客户名称,0] & ""开票汇总""> "
        End If
    End If
Else
    If kpn.text  > "" Then
        If kpy.text  > "" Then
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年"" & [@开票主表,月,0] & ""月 开票汇总""> "
        Else
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年 开票汇总""> "
        End If
    Else
        If kpy.text  > "" Then
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,月,0] & ""月 开票汇总""> "
        Else
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & ""开票汇总""> "
        End If
    End If
End If
Book.Build() \'生成报表
Book.Save(fl)
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
App.Visible = True
Ws.PrintPreview
App.Quit

 

这句代码应该怎么修正呢

[此贴子已经被作者于2016/8/1 18:25:42编辑过]

--  作者:大红袍
--  发布时间:2016/8/1 18:36:00
--  
Dim r As Row = Tables("开票主表").Current
Dim Book As New XLS.Book(ProjectPath & "Attachments\\开票汇总清单.xls") \'打开模板
Dim fl As String = "d:/开票信息/"+(r("客户名称"))+(r("年")) +"年"+ (r("月"))   +"月 开票汇总清单.xls"
If FileSys.FileExists("fl") Then \'如果指定的文件存在
    FileSys.DeleteFile("fl",2,2) \'则彻底删除之
End If
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年"" & [@开票主表,月,0] & ""月"" & [@开票主表,客户名称,0] & ""开票汇总""> "
Book.Build() \'生成报表
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
Proc.Start()

--  作者:hongyefor
--  发布时间:2016/8/1 18:39:00
--  

不要告诉我要一行一行修正吧

If cj.text  > "" Then
    If kpn.text  > "" Then
        If kpy.text  > "" Then
            Dim fl As String ="d:/开票信息/"+ (r("年"))  +"年" + (r("月"))   +"月" +(r("客户名称"))+"开票汇总清单.xls"
        Else
            Dim fl As String ="d:/开票信息/"+ (r("年"))  +"年" +(r("客户名称"))+"开票汇总清单.xls"
        End If
    Else
        If kpy.text  > "" Then
            Dim fl As String ="d:/开票信息/"+ (r("月"))   +"月" +(r("客户名称"))+"开票汇总清单.xls"
        Else
            Dim fl As String ="d:/开票信息/"+ (r("客户名称"))+"开票汇总清单.xls"
        End If
    End If
Else
    If kpn.text  > "" Then
        If kpy.text  > "" Then
            Dim fl As String ="d:/开票信息/"+ (r("年"))  +"年" + (r("月"))   +"月 开票汇总清单.xls"
        Else
            Dim fl As String ="d:/开票信息/"+ (r("年"))  + "年 开票汇总""> "
        End If
    Else
        If kpy.text  > "" Then
            Dim fl As String ="d:/开票信息/"+ (r("月"))   +"月 开票汇总清单.xls"
        Else
            Dim fl As String ="d:/开票信息/" + "开票汇总清单.xls"
        End If
    End If
End If

[此贴子已经被作者于2016/8/1 18:39:14编辑过]

--  作者:大红袍
--  发布时间:2016/8/1 18:42:00
--  

Dim cj As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim dm As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim hm As WinForm.ComboBox = e.Form.Controls("ComboBox3")
Dim kpn As WinForm.ComboBox = e.Form.Controls("ComboBox4")
Dim kpy As WinForm.ComboBox = e.Form.Controls("ComboBox5")
Dim r As Row = Tables("开票主表").Current
Dim Book As New XLS.Book(ProjectPath & "Attachments\\开票汇总清单.xls") \'打开模板
Dim fl As String = ""
If cj.text  > "" Then
    If kpn.text  > "" Then
        If kpy.text  > "" Then
            fl ="d:/开票信息/"+ (r("年"))  +"年" + (r("月"))   +"月" +(r("客户名称"))+"开票汇总清单.xls"
        Else
            fl ="d:/开票信息/"+ (r("年"))  +"年" +(r("客户名称"))+"开票汇总清单.xls"
        End If
    Else
        If kpy.text  > "" Then
            fl ="d:/开票信息/"+ (r("月"))   +"月" +(r("客户名称"))+"开票汇总清单.xls"
        Else
            fl ="d:/开票信息/"+ (r("客户名称"))+"开票汇总清单.xls"
        End If
    End If
Else
    If kpn.text  > "" Then
        If kpy.text  > "" Then
            fl ="d:/开票信息/"+ (r("年"))  +"年" + (r("月"))   +"月 开票汇总清单.xls"
        Else
            fl ="d:/开票信息/"+ (r("年"))  + "年 开票汇总""> "
        End If
    Else
        If kpy.text  > "" Then
            fl ="d:/开票信息/"+ (r("月"))   +"月 开票汇总清单.xls"
        Else
            fl ="d:/开票信息/" + "开票汇总清单.xls"
        End If
    End If
End If

If FileSys.FileExists("fl") Then \'如果指定的文件存在
    FileSys.DeleteFile("fl",2,2) \'则彻底删除之
End If
Dim Sheet As XLS.Sheet = Book.Sheets(0)
If cj.text  > "" Then
    If kpn.text  > "" Then
        If kpy.text  > "" Then
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年"" & [@开票主表,月,0] & ""月"" & [@开票主表,客户名称,0] & ""开票汇总""> "
        Else
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年"" & [@开票主表,客户名称,0] & ""开票汇总""> "
        End If
    Else
        If kpy.text  > "" Then
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,月,0] & ""月"" & [@开票主表,客户名称,0] & ""开票汇总""> "
        Else
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & ""  "" & [@开票主表,客户名称,0] & ""开票汇总""> "
        End If
    End If
Else
    If kpn.text  > "" Then
        If kpy.text  > "" Then
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年"" & [@开票主表,月,0] & ""月 开票汇总""> "
        Else
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,年,0] & ""年 开票汇总""> "
        End If
    Else
        If kpy.text  > "" Then
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & [@开票主表,月,0] & ""月 开票汇总""> "
        Else
            Sheet(1,1).Value = "<[@企业信息,企业名称,0] & ""开票汇总""> "
        End If
    End If
End If

Book.Build() \'生成报表
Book.Save(fl)
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
App.Visible = True
Ws.PrintPreview
App.Quit