专业报表
Tables("退休慰问费").OpenView("1") Dim doc As New PrintDoc Dim rt As Prt.RenderTable Dim rx,rx1,rx2 As prt.RenderText Dim Agg As New prt.DataBinding.Aggregate("GroupSum") Dim tbl As Table = Tables("退休慰问费") Dim ColNames As New List(Of String) Dim Rows As List(Of DataRow) Dim Regions As List(Of String) = tbl.DataTable.GetUniqueValues("","慰问单位") For Each cl As Col In tbl.Cols '排除隐藏列 If cl.Visible Then ColNames.Add(cl.Name) End If Next For Each Region As String In Regions rx1 = New prt.RenderText rx1.Style.FontSize = 14 rx1.Style.FontBold = True rx1.Style.Spacing.Bottom = 2 rx1.Text = "退休慰问费" rx1.Style.TextAlignHorz = prt.AlignHorzEnum.Center doc.Body.Children.Add(rx1) rx = New prt.RenderText rx.Style.FontSize = 11 rx.Style.FontBold = True rx.Style.Spacing.Bottom = 2 rx.Text = " 慰问单位: " & Region & " ".PadLeft(90) & " 单位: 元" doc.Body.Children.Add(rx) rt = New prt.RenderTable rt.Style.Font = Tables("退休慰问费").Font rt.Style.TextAlignVert = prt.AlignVertEnum.Center rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray) rt.Style.Spacing.Bottom = 5 rt.CellStyle.Spacing.All = 1 rt.Style.Font = tbl.Font Rows = tbl.Datatable.Select("[是否停发] = False and [慰问单位] = '" & Region & "'") For c As integer = 0 To ColNames.Count - 1 '逐列设置和填入内容 rt.Cells(0,c).Text = ColNames(c) '列名作为标题 rt.Cols(c).Width = tbl.Cols(ColNames(c)).PrintWidth For r As integer = 0 To Rows.Count -1 rt.Cells(r + 1, c).Text = Rows(r)(ColNames(c)) Next Next
rt.Rows.Count = rt.Rows.Count + 1 Dim cnt As integer = rt.Rows.Count - 1 rt.Cells(cnt,0).Text = "总计" For c As Integer = 0 To ColNames.Count - 1 '逐列设置和填入内容 If tbl.Cols(ColNames(c)).IsNumeric then rt.Cells(cnt,c).Text = tbl.Compute("Sum("& ColNames(c) & ")","[是否停发] = False and [慰问单位] = '" & Region & "'") End If Next rt.Cells(cnt+1,0).SpanCols = ColNames.Count
rt.Cells(cnt+1,0).Text = "单位负责人:" & " ".PadLeft(16) & "人事负责人:"& " ".PadLeft(16) & "制表人:" rt.Cells(cnt+1,0).Style.GridLines.Bottom = New prt.LineDef(Color.White) rt.Cells(cnt+1,0).Style.GridLines.Left = New prt.LineDef(Color.White) rt.Cells(cnt+1,0).Style.GridLines.Right = New prt.LineDef(Color.White) rt.Rows(cnt+1).Style.Font = New Font("宋体",11, FontStyle.Bold) doc.Body.Children.Add(rt) Next doc.preview() Tables("退休慰问费").OpenView("2")
|