Dim bt3 As WinForm.Label = e.Form.Controls("Label3")
Dim doc As New PrintDoc '定义一个新报表
Dim rt As New prt.RenderTable '定义一个新表格
Dim rs As New prt.RenderText()
Dim tb As Table = Tables("查询与统计_table3")
Dim hd As Integer = tb.HeaderRows '获得表头的层数
Dim cnt As Integer '用于记录列位置
'rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
rt.Style.Font = tb.Font
tb.CreateReportHeader(rt, True) '生成表头,排除隐藏列
For c As Integer = 0 To tb.Cols.Count - 1 '逐列设置和填入内容
If tb.Cols(c).Visible Then
rt.Cols(cnt).Width = tb.Cols(c).PrintWidth '列宽等于实际列宽
If tb.Cols(c).IsNumeric OrElse tb.Cols(c).IsDate Then '如果是数值或日期列
rt.Cols(cnt).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
'If tb.Cols(c).name Like "*率*" Or tb.Cols(c).name Like "*占比*" Or tb.Cols(c).name Like "*拉动*" Then
'tb.Cols(c).DataCol.SetFormat("0.00%")
'End If
End If
For r As Integer = 0 To tb.Rows.Count - 1 '开始填入该列内容
rt.Cells(r + hd, cnt).Text = tb(r, c)
Next
cnt = cnt + 1
End If
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
rt.CellStyle.Spacing.All = 3
'0.5 '单元格内距设为0.5毫米
rt.RowGroups(0, tb.HeaderRows).Header = prt.TableHeaderEnum.All '利用行组功能设置表头
rt.Style.Spacing.Top = 4 '表格和前面对象的垂直距离为4毫米
'rt.Style.FontSize = 12
rs.Text = bt3.text
rs.Style.Font = New Font("宋体", 24 , FontStyle.Bold) '设置文本对象的字体
rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本水平居中
doc.Body.Children.add(rs) '将文本对象加入到表格
doc.Body.Children.Add(rt) '将表格加入到报表
Dim rx As New prt.RenderTable
rx.Cells(0, 0).Text = Date.Today
rx.Cells(0, 1).Text = bt3.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 '作为页眉使用
doc.PageFooter = rx
doc.Preview()
求助:1、实现打印百分比(先判断字段i属性)
'If tb.Cols(c).name Like "*率*" Or tb.Cols(c).name Like "*占比*" Or tb.Cols(c).name Like "*拉动*" Then
'tb.Cols(c).DataCol.SetFormat("0.00%")
'End If
2、实现每页都显示标题
rs.Text = bt3.text
我的前段代码,实现不了上述目的,求教了