以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关于“动态设置打印条件”  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=81030)

--  作者:digger_deng
--  发布时间:2016/2/16 21:03:00
--  关于“动态设置打印条件”
请教专家:
我想通过父表的“序号”来控制子表的打印报表,代码如下:
Dim xh1 As String

xh1=Tables("课程表").Current("序号") 

Dim Book As New XLS.Book(ProjectPath & "Attachments\\升班通知1.xls") \'打开模板
Dim fl As String = ProjectPath & "Reports\\升班通知1.xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(2,7).Value = "<序号 = " & xh1 & ">"
Book.Build() \'生成报表
Book.Save(fl) 
Dim Proc As New Process 
Proc.File = fl
Proc.Start()
执行的结果只是空白的Excel表

如果改成固定的内容就没有问题
Dim Book As New XLS.Book(ProjectPath & "Attachments\\升班通知1.xls") \'打开模板
Dim fl As String = ProjectPath & "Reports\\升班通知1.xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Sheet(2,7).Value = "<序号 = \'E002\'>"
Book.Build() \'生成报表
Book.Save(fl) 
Dim Proc As New Process 
Proc.File = fl
Proc.Start()



--  作者:大红袍
--  发布时间:2016/2/16 21:08:00
--  

单引号要加上

 

Sheet(2,7).Value = "<序号 = \'" & xh1 & "\'>"