Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
Dim doc As PrintDoc = e.Form.GernatePrintDoc()
doc.Preview()
这句代码是打印这个窗口的,
'Dim grp As WinForm.table = e.Form.Controls("Table1")
'Dim doc As PrintDoc = e.Form.GernatePrintDoc(grp)
'doc.Preview()
这句代码会报错的,麻烦给给正常的代码谢谢
Dim doc As New PrintDoc
Dim tb As Table = Tables("统计查询_Table1")
Dim prs As Integer = 40 '每页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
For r As Integer = p * prs To math.min(tb.Rows.Count - 1, ( p + 1) * prs - 1)
rt.Cells(r - p * prs + 1, c).Text = tb.rows(r)(c)
Next
Next
If p < math.Ceiling(tb.Rows.Count / prs) - 1 Then
rt.BreakAfter = prt.BreakEnum.Page
End If
doc.Body.Children.Add(rt)
Next
doc.Preview()
老师刚刚我用这个方法实现了,,但是列宽要在在那个位置设置,,,还有隐藏的列不想打印,怎么设置,,给调整一下代码呗,谢谢
老师你给的这句代码好像就是隐藏了数据,,格子还在,,页面左右上下间距是怎么设置的,麻烦再统计窗口的打印给调试一下,我学习学习
下载信息 [文件大小: 下载次数: ] | |
点击浏览该文件:税piao管理.rar |
Dim doc As New PrintDoc
Dim tb As Table = Tables("统计查询_Table1")
Dim prs As Integer = 38 '每页20行
For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1
Dim rt As New prt.RenderTable
Dim rx As New prt.RenderText
Dim ra As New prt.RenderArea '定义一个容器
ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never '禁止容器因为分页而被垂直分割
rx.text = "月统计奖励表"
rx.Style.FontBold = True '字体加粗
rx.Style.FontSize = 16 '大体大小为16磅
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
rx.Style.Spacing.Bottom = 3 '和下面的对象(表格)距离3毫米
ra.Children.Add(rx)
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 0.5
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 15 '设置上边距
Doc.PageSetting.BottomMargin = 15 '设置下边距
rt.Width = "Parent.Width" '对象宽度等于页面宽度
rt.Height = "Parent.Height" '对象高度等于页面高度
rt.Style.FontSize = 12 '大体大小为16磅
rt.Cols(0).Width = 60 '设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列)
rt.Cols(1).Width = 30
rt.Cols(2).Width = 30
Dim idx As Integer = 0
For c As Integer = 0 To tb.Cols.Count - 1
If tb.Cols(c).Visible = True Then
rt.Cells(0, idx).Text = tb.Cols(c).Name
For r As Integer = p * prs To math.min(tb.Rows.Count - 1, ( p + 1) * prs - 1)
rt.Cells(r - p * prs + 1, idx).Text = tb.rows(r)(c)
Next
idx += 1
End If
Next
If p < math.Ceiling(tb.Rows.Count / prs) - 1 Then
rt.BreakAfter = prt.BreakEnum.Page
End If
ra.Children.Add(rt)
Doc.Body.ChildRen.Add(ra)
Next
doc.Preview()
老师我加了个标题,,下面的表格不会显示了,,红色的改的,看不出哪里的毛病,,麻烦给看一下