版主,我想通过模板打印报表,同时加入水印,您看代码需要怎么写!谢谢!
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 doc As New PrintDoc
Dim rt As New prt.RenderText
doc.body.Children.Add(rt)
rt = New prt.RenderText '设置文本对象的内容
rt.Text= "制表:" & User.Name
rt.Width = "Parent.Width" '宽度等于页面宽度
rt.Height = "Parent.Height" '高度等于页面高度
rt.Style.TextAngle = 45 '旋转45度
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中对齐
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中对齐
rt.Style.FontSize = 72 '字体大小为8磅
rt.Style.TextColor = Color.Gray '文本颜色为灰色
Doc.WaterMark = rt '作为页眉使用
Sheet(3,0).Value = "<客户明细, 1>" '细节区定义一
Sheet(12,0).Value = "<客户明细>" '细节区定义二
Sheet(2,4).Value = "数据日期:"& Date.Today()
Sheet(2,5).Value = "制表:" & User.Name '修改模板,加入制单人信息
Book.Build() '生成报表
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
Proc.Start()