Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共10 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]副标题不在一条水平线上

1楼
易服 发表于:2008/10/8 14:55:00

副标题不在一条水平线上

图片点击可在新窗口打开查看此主题相关图片如下:副标题.jpg
图片点击可在新窗口打开查看

Dim doc As New PrintDoc '副标题
Dim rt3 As prt.RenderText '定义一个文本对象
dim s as string
s = "乡名:"
s = s & CurrentTable(0,1)
rt3 = New prt.RenderText '设置文本对象的内容
rt3.Text = s '设置文本内容
rt3.Style.TextAlignHorz = prt.AlignHorzEnum.left '靠中
rt3.Style.FontSize = 12 '字体大小为8磅
doc.Body.Children.Add(rt3) '设置标题
Dim rt4 As prt.RenderText '定义一个文本对象
dim t as string
t = "造林年度:"
t = t & CurrentTable(0,0)
rt4 = New prt.RenderText '设置文本对象的内容
rt4.Text = t '设置文本内容
rt4.Style.TextAlignHorz = prt.AlignHorzEnum.Center '靠中
rt4.Style.FontSize = 12 '字体大小为8磅
doc.Body.Children.Add(rt4)
Dim rt5 As prt.RenderText '定义一个文本对象
dim v as string
v = "单位:亩.株.元.个.分米.株/亩"
rt5 = New prt.RenderText '设置文本对象的内容
rt5.Text = v '设置文本内容
rt5.Style.TextAlignHorz = prt.AlignHorzEnum.right '靠中
rt5.Style.Padding.Bottom = 0.5 '底端内容缩进0.5毫米
rt5.Style.FontSize = 12 '字体大小为8磅
doc.Body.Children.Add(rt5) '设置标题
Dim rx2 As New prt.RenderTable
rx2.Cells(0,1).Text = "退耕还林工程小班作业一览表"
rx2.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx2.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx2.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
rx2.Style.FontSize = 18 '字体大小为8磅
Doc.PageHeader = rx2 '作为页眉使用 '设置页眉
Dim rx1 As New prt.RenderTable
rx1.Cells(0,1).Text = "调查:"
rx1.Cells(0,5).Text = "第[PageNo]页,共[PageCount]页"
rx1.Cells(0,10).Text = "调查日期:"
rx1.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx1.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
'rx1.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
rx1.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
rx1.Style.FontSize = 8 '字体大小为8磅
Doc.PageFooter = rx1 '作为页眉使用

Dim rt As New prt.RenderTable
Dim tb as Table = Tables("总览")
Dim ColNames As String() = New String(){ "村名", "小班号", "图幅号","农户数", "小地名", "权属", "设计面积", "造林类别", "林种", "立地类型", "平均坡度", "坡向", "土层厚度", "主要树种", "次要树种", "混交比", "造林密度", "整地方式", "整地时间", "整地规格", "造林方式", "造林时间", "抚育次数", "抚育时间", "种源类型", "需苗量", "苗木规格", "用工量", "投资概算" }
rt.Style.GridLines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 1
rt.CanSplitHorz = True '表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font

For c As Integer = 0 To ColNames.Length - 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
    rt.Cells(1, c).Text = "[Fields!" & ColNames(c) & ".Value]"
Next
rt.Cells(2,0).Text ="小计"
rt.Cells(2,0).SpanCols = 1
rt.Cells(2,6).Text = "[Aggregates!设计面积小计.Value]"
rt.Cells(2,25).Text = "[Aggregates!需苗量小计.Value]"
rt.Cells(2,27).Text = "[Aggregates!用工量小计.Value]"
rt.Cells(2,28).Text = "[Aggregates!投资概算小计.Value]"
rt.Cells(3,0).Text ="总计"
rt.Cells(3,0).SpanCols = 1
rt.Cells(3,6).Text = "[Aggregates!设计面积总计.Value]"
rt.Cells(3,25).Text = "[Aggregates!需苗量总计.Value]"
rt.Cells(3,27).Text = "[Aggregates!用工量总计.Value]"
rt.Cells(3,28).Text = "[Aggregates!投资概算总计.Value]"
rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
With rt.RowGroups(1,2)
    .DataBinding.DataSource = BindTables("总览")
    .DataBinding.Grouping.Expressions.Add("Fields!村名.Value")
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("设计面积小计", "Fields!设计面积.Value", .DataBinding, 1, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("需苗量小计", "Fields!需苗量.Value", .DataBinding, 1, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("设计面积总计", "Fields!设计面积.Value", .DataBinding, 0, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("需苗量总计", "Fields!需苗量.Value", .DataBinding, 0, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("用工量小计", "Fields!用工量.Value", .DataBinding, 1, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("投资概算小计", "Fields!投资概算.Value", .DataBinding, 1, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("用工量总计", "Fields!用工量.Value", .DataBinding, 0, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("投资概算总计", "Fields!投资概算.Value", .DataBinding, 0, 0))
doc.PageSetting.Landscape = True '横向打印
Doc.PageSetting.LeftMargin = 5 '设置左边距
Doc.PageSetting.RightMargin = 5 '设置右边距
Doc.PageSetting.TopMargin = 20 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距

End With
rt.RowGroups(1,1).DataBinding.DataSource = BindTables("总览")
doc.Body.Children.Add(rt)

doc.Preview()

2楼
贺老六 发表于:2008/10/8 15:21:00
呵呵,怎么能这样设计标题啊,报表的基础你还没有掌握,完全是生搬硬套而已。
按顺序加入的对象,每一个对象占据一行,根本就不在同一行的。

可以用页眉页脚类似的方式来解决,请参考:

 开发指南 - 专业报表 - 表格基础 - 表格和页眉页脚。
3楼
易服 发表于:2008/10/8 15:36:00
用页眉页脚类似的方式来解决,乡名、造林年度后面能根据筛选结果来填充吗?
4楼
狐狸爸爸 发表于:2008/10/8 15:41:00

呵呵,可以啊,道理是一样的。
不同的是,建立了一个包括三个单元格的表格,原来的三个副标题分别放在这三个单元格中而已。

5楼
gdtgl 发表于:2008/10/8 17:49:00

页眉页脚是每页必有(不需要每页都要打印的时候就不能用)

[此贴子已经被作者于2008-10-9 1:16:47编辑过]
6楼
gdtgl 发表于:2008/10/8 17:53:00

Dim doc As New PrintDoc

'副标题
Dim rt3 As prt.RenderText '定义一个文本对象
dim s as string
s = "乡名:"
s = s & CurrentTable(0,1)
rt3 = New prt.RenderText '设置文本对象的内容
rt3.Text = s '设置文本内容
rt3.Style.FontSize = 12 '字体大小为8磅
doc.Body.Children.Add(rt3) '设置标题
rt3.x=7
rt3.y=27


Dim rt4 As prt.RenderText '定义一个文本对象
dim t as string
t = "造林年度:"
t = t & CurrentTable(0,0)
rt4 = New prt.RenderText '设置文本对象的内容
rt4.Text = t '设置文本内容
rt4.Style.FontSize = 12 '字体大小为8磅
doc.Body.Children.Add(rt4)
rt4.x=128
rt4.y=27

 

Dim rt5 As prt.RenderText '定义一个文本对象
dim v as string
v = "单位:亩.株.元.个.分米.株/亩"
rt5 = New prt.RenderText '设置文本对象的内容
rt5.Text = v '设置文本内容
rt5.Style.TextAlignHorz = prt.AlignHorzEnum.right '靠中
rt5.Style.Padding.Bottom = 0.5 '底端内容缩进0.5毫米
rt5.Style.FontSize = 12 '字体大小为8磅
doc.Body.Children.Add(rt5) '设置标题

 

 

Dim rx2 As New prt.RenderTable
rx2.Cells(0,1).Text = "退耕还林工程小班作业一览表"
rx2.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx2.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx2.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
rx2.Style.FontSize = 18 '字体大小为8磅
Doc.PageHeader = rx2 '作为页眉使用 '设置页眉


Dim rx1 As New prt.RenderTable
rx1.Cells(0,1).Text = "调查:"
rx1.Cells(0,5).Text = "第[PageNo]页,共[PageCount]页"
rx1.Cells(0,10).Text = "调查日期:"
rx1.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx1.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
'rx1.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
rx1.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
rx1.Style.FontSize = 8 '字体大小为8磅
Doc.PageFooter = rx1 '作为页眉使用

Dim rt As New prt.RenderTable
Dim tb as Table = Tables("总览")
Dim ColNames As String() = New String(){ "村名", "小班号", "图幅号","农户数", "小地名", "权属", "设计面积", "造林类别", "林种", "立地类型", "平均坡度", "坡向", "土层厚度", "主要树种", "次要树种", "混交比", "造林密度", "整地方式", "整地时间", "整地规格", "造林方式", "造林时间", "抚育次数", "抚育时间", "种源类型", "需苗量", "苗木规格", "用工量", "投资概算" }
rt.Style.GridLines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 1
rt.CanSplitHorz = True '表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font

For c As Integer = 0 To ColNames.Length - 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
    rt.Cells(1, c).Text = "[Fields!" & ColNames(c) & ".Value]"
Next
rt.Cells(2,0).Text ="小计"
rt.Cells(2,0).SpanCols = 1
rt.Cells(2,6).Text = "[Aggregates!设计面积小计.Value]"
rt.Cells(2,25).Text = "[Aggregates!需苗量小计.Value]"
rt.Cells(2,27).Text = "[Aggregates!用工量小计.Value]"
rt.Cells(2,28).Text = "[Aggregates!投资概算小计.Value]"
rt.Cells(3,0).Text ="总计"
rt.Cells(3,0).SpanCols = 1
rt.Cells(3,6).Text = "[Aggregates!设计面积总计.Value]"
rt.Cells(3,25).Text = "[Aggregates!需苗量总计.Value]"
rt.Cells(3,27).Text = "[Aggregates!用工量总计.Value]"
rt.Cells(3,28).Text = "[Aggregates!投资概算总计.Value]"
rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
With rt.RowGroups(1,2)
    .DataBinding.DataSource = BindTables("总览")
    .DataBinding.Grouping.Expressions.Add("Fields!村名.Value")
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("设计面积小计", "Fields!设计面积.Value", .DataBinding, 1, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("需苗量小计", "Fields!需苗量.Value", .DataBinding, 1, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("设计面积总计", "Fields!设计面积.Value", .DataBinding, 0, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("需苗量总计", "Fields!需苗量.Value", .DataBinding, 0, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("用工量小计", "Fields!用工量.Value", .DataBinding, 1, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("投资概算小计", "Fields!投资概算.Value", .DataBinding, 1, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("用工量总计", "Fields!用工量.Value", .DataBinding, 0, 0))
    doc.DataSchema.Aggregates.Add(New prt.DataBinding.Aggregate("投资概算总计", "Fields!投资概算.Value", .DataBinding, 0, 0))
doc.PageSetting.Landscape = True '横向打印
Doc.PageSetting.LeftMargin = 5 '设置左边距
Doc.PageSetting.RightMargin = 5 '设置右边距
Doc.PageSetting.TopMargin = 20 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距

End With
rt.RowGroups(1,1).DataBinding.DataSource = BindTables("总览")
doc.Body.Children.Add(rt)

doc.Preview()

[此贴子已经被作者于2008-10-9 1:15:12编辑过]
7楼
ylm 发表于:2008/10/9 15:19:00

简单笨办法: 将三个副标题用 & 加空格 连接起来吧.

8楼
易服 发表于:2008/10/10 9:22:00
谢谢了!还怕没人指导几天没有上论坛,还想问一下用页眉的方法怎么办,自己试了几次无结果。
9楼
贺老六 发表于:2008/10/10 9:33:00
你原来的太乱了,我重新写了一个标准的设置方法:

 

Dim doc As New PrintDoc '副标题

Dim rx As prt.RenderText '定义一个文本对象

Dim rt As New prt.RenderTable

 

rx = New prt.RenderText

rx.Text = "主标题"

rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '主标题居中

rx.Style.FontSize = 18 '字体大小为18磅

rx.Style.FontBold = True

rx.style.Spacing.Bottom = 5 '和以下对象保持5毫米的距离

Doc.Body.Children.add(rx)

 

rx = New prt.RenderText

rx.Text = "左标题"

rx.Style.TextAlignHorz = prt.AlignHorzEnum.left '靠左

rx.Style.FontSize = 12 '字体大小为18磅

rt.cells(0,0).RenderObject = rx

 

rx = New prt.RenderText

rx.Text = "中标题"

rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '居中

rx.Style.FontSize = 12 '字体大小为18

rt.cells(0,1).RenderObject = rx

 

rx = New prt.RenderText

rx.Text = "右标题"

rx.Style.TextAlignHorz = prt.AlignHorzEnum.Right '靠右

rx.Style.FontSize = 12 '字体大小为18

rt.cells(0,2).RenderObject = rx

 

doc.Body.Children.Add(rt)

doc.preview

10楼
kylin 发表于:2008/10/10 10:31:00
学习了,多谢!
共10 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03906 s, 2 queries.