-- 作者:大红袍
-- 发布时间:2015/10/12 11:23:00
--
专业报表,就参考代码来写
Dim doc As New PrintDoc Dim tb As Table = Tables("学生信息") Dim prs As Integer = 20 \'每页20行 For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1 Dim rt As New prt.RenderTable rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) rt.CellStyle.Spacing.All = 0.5 For c As Integer = 0 To tb.Cols.Count - 1 rt.Cells(0,c).Text = tb.Cols(c).Name Next For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1) For c As Integer = 0 To tb.Cols.Count - 1 rt.Cells(r - p * prs + 1, c).Text = tb.rows(r)(c) Next Next If p = math.Ceiling(tb.Rows.Count / prs) - 1 \'如果是最后一页 For r As Integer = tb.Rows.Count To ( p + 1) * prs - 1 \'补空行 rt.Rows.Count = rt.Rows.Count + 1 rt.Rows(rt.Rows.count -1)(0).text = " " Next Else rt.BreakAfter = prt.BreakEnum.Page \'否则换页 End If doc.Body.Children.Add(rt) Next
\'页眉 Dim rx As New prt.RenderTable rx.Cells(0,0).Text = Date.Today rx.Cells(0,1).Text = "抗震救灾专题" rx.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页" rx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left rx.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center rx.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right rx.Style.Borders.Bottom = New prt.LineDef \'设置底边框 rx.CellStyle.Spacing.Bottom = 0.5 \'底端内容缩进0.5毫米 rx.Style.FontSize = 8 \'字体大小为8磅 Doc.PageHeader = rx \'作为页眉使用
\'页脚 rx = New prt.RenderTable rx.Cells(0,0).Text = Date.Today rx.Cells(0,1).Text = "抗震救灾专题" rx.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页" rx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left rx.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center rx.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right rx.Style.Borders.Bottom = New prt.LineDef \'设置底边框 rx.CellStyle.Spacing.Bottom = 0.5 \'底端内容缩进0.5毫米 rx.Style.FontSize = 8 \'字体大小为8磅 Doc.PageFooter = rx \'作为页眉使用
doc.Preview()
|
-- 作者:良才
-- 发布时间:2015/10/13 8:00:00
--
谢谢!还想问个问题,"制单人:" & User.Name 在表格中水平居中?
Dim Book As New XLS.Book(ProjectPath & "报表模板\\资助汇总表.xls") Dim fl As String = ProjectPath & "Reports\\资助汇总表.xls" Dim Sheet As XLS.Sheet = Book.Sheets(0) Sheet(4,5).Value = "制单人:" & User.Name \'修改模板,加入制单人信息 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.PrintOut App.Quit
|
-- 作者:Hyphen
-- 发布时间:2015/10/13 8:52:00
--
......
Sheet(4,5).Value = "制单人:" & User.Name \'修改模板,加入制单人信息
Dim Style As XLS.Style = Book.NewStyle() \'定义新样式 Style.AlignHorz = XLS.AlignHorzEnum.Center Style.Font = Sheet(4,5).Style.Font Sheet(4,5).Style= Style Book.Build()
......
|