以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]每頁都能打印標題  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91216)

--  作者:GD007
--  发布时间:2016/10/3 17:39:00
--  [求助]每頁都能打印標題
Dim doc As New PrintDoc \'定义一个新报表
Dim rt As New prt.RenderTable \'定义一个新表格
Dim tb As Table = Tables("员工资料")
doc.PageSetting.Landscape = True \'横向打印
Dim ColNames As New List(Of String)
For Each cl As Col In tb.Cols \'排除隐藏列
    If cl.Visible Then
        ColNames.Add(cl.Name)
    End If
Next
rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font
Dim rx As New prt.RenderText
    rx.Text = "資料打印2016臺帳報表"
    rx.Style.Font = New Font("宋体", 14, FontStyle.Bold) 
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rx.Style.Spacing.Bottom = 3
    Doc.body.Children.Add(rx)

For c As Integer = 0 To ColNames.Count - 1 \'逐列设置和填入内容
    rt.Cells(0,c).Text = ColNames(c) \'列名作为标题
    rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中
    rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth \'列宽等于实际列宽
    If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then \'如果是数值或日期列
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右
    End If
    For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
        rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
    Next
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线
rt.CellStyle.Spacing.All = 2.0 \'单元格内距设为1.0毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头.
doc.Body.Children.Add(rt) \'将表格加入到报表
doc.Preview()


請問每頁都能打印標題,在哪個地方加入代碼,加入什麽代碼。

--  作者:狐狸爸爸
--  发布时间:2016/10/3 19:38:00
--  
参考:
http://www.foxtable.com/webhelp/scr/1214.htm
http://www.foxtable.com/webhelp/scr/1215.htm
http://www.foxtable.com/webhelp/scr/2735.htm

--  作者:GD007
--  发布时间:2016/10/4 9:12:00
--  
我能看看就明白,那就不用問了。求直接解決。
--  作者:狐狸爸爸
--  发布时间:2016/10/4 9:37:00
--  
1、我提供的链接有问题说明,有解决办法,有实例,请花点时间学习
2、我提供的是技术支持,我不是你的免费代码编写器,


--  作者:狐狸爸爸
--  发布时间:2016/10/4 10:29:00
--  
Dim doc As New PrintDoc \'定义一个新报表
Dim rt As New prt.RenderTable \'定义一个新表格
Dim tb As Table = Tables("表A")
doc.PageSetting.Landscape = True \'横向打印
Dim ColNames As New List(Of String)
For Each cl As Col In tb.Cols \'排除隐藏列
    If cl.Visible Then
        ColNames.Add(cl.Name)
    End If
Next
rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font
rt.Cells(0,0).text = "資料打印2016臺帳報表"
rt.Cells(0,0).SpanCols = 6 \'合并第一行全部单元格,用于显示主标题
rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主标题居中
rt.Cells(0,0).Style.Font = New Font("宋体", 16, FontStyle.Bold) \'设置主标题字体
rt.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第一行的网格线?
rt.Rows(0).Style.Borders.Bottom = New prt.Linedef

For c As Integer = 0 To ColNames.Count - 1 \'逐列设置和填入内容
    rt.Cells(1,c).Text = ColNames(c) \'列名作为标题
    rt.Cells(1,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中
    rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth \'列宽等于实际列宽
    If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then \'如果是数值或日期列
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右
    End If
    For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
        rt.Cells(r + 2, c).Text = tb.Rows(r)(ColNames(c))
    Next
Next
rt.cells(0,0).SpanCols = rt.Cols.Count
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线
rt.CellStyle.Spacing.All = 2.0 \'单元格内距设为1.0毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
rt.RowGroups(0,2).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头.
doc.Body.Children.Add(rt) \'将表格加入到报表
doc.Preview()
[此贴子已经被作者于2016/10/4 10:30:18编辑过]

--  作者:GD007
--  发布时间:2016/10/4 11:10:00
--  
非常感謝,問題解決了,非常感謝,非常感謝,不斷學習中。
--  作者:大雪山
--  发布时间:2016/10/5 20:23:00
--  
每一页将第一行作为表头的字体能独立设置就更加完美,现在是同表内字体相同,盼望狐狸爸爸再次出手,帮我解决我这一困惑.
--  作者:狐狸爸爸
--  发布时间:2016/10/5 22:26:00
--  
原来的代码中已经有一行:
rt.Cells(0,0).Style.Font = New Font("宋体", 16, FontStyle.Bold) \'设置主标题字体
直接套用不会吗:

Dim doc As New PrintDoc \'定义一个新报表
Dim rt As New prt.RenderTable \'定义一个新表格
Dim tb As Table = Tables("表A")
doc.PageSetting.Landscape = True \'横向打印
Dim ColNames As New List(Of String)
For Each cl As Col In tb.Cols \'排除隐藏列
    If cl.Visible Then
        ColNames.Add(cl.Name)
    End If
Next
rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font
rt.Cells(0,0).text = "資料打印2016臺帳報表"
rt.Cells(0,0).SpanCols = 6 \'合并第一行全部单元格,用于显示主标题
rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主标题居中
rt.Cells(0,0).Style.Font = New Font("宋体", 16, FontStyle.Bold) \'设置主标题字体
rt.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第一行的网格线?
rt.Rows(0).Style.Borders.Bottom = New prt.Linedef
For c As Integer = 0 To ColNames.Count - 1 \'逐列设置和填入内容
    rt.Cells(1,c).Text = ColNames(c) \'列名作为标题
    rt.Cells(1,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中
    rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth \'列宽等于实际列宽
    If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then \'如果是数值或日期列
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右
    End If
    For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
        rt.Cells(r + 2, c).Text = tb.Rows(r)(ColNames(c))
    Next
Next
rt.cells(0,0).SpanCols = rt.Cols.Count
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线
rt.CellStyle.Spacing.All = 2.0 \'单元格内距设为1.0毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
rt.Rows(1).Style.Font = New Font("宋体", 16, FontStyle.Bold)
rt.RowGroups(0,2).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头.
doc.Body.Children.Add(rt) \'将表格加入到报表
doc.Preview()

http://www.foxtable.com/webhelp/scr/1206.htm
http://www.foxtable.com/webhelp/scr/1179.htm