以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]请加上标题、副标题、页脚 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=774) |
-- 作者:易服 -- 发布时间:2008/10/5 23:53:00 -- [求助]请加上标题、副标题、页脚 以下代码是我东拼西凑而成可以执行,还需加上标题、副标题、页脚 标题(居中):退耕还林工程小班作业一览表 副标题(同表宽):乡名:[乡名] 造林年度:[造林年度] 单位:亩 页脚(同表宽):调查: 第?页 共?页 调查日期: Dim doc As New PrintDoc 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-5 23:56:39编辑过]
|
-- 作者:gdtgl -- 发布时间:2008/10/6 2:03:00 -- Dim doc As New PrintDoc \'副标题 \'设置标题
\'设置页眉 Dim rt As New prt.RenderTable For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内容 End With doc.Preview() |
-- 作者:gdtgl -- 发布时间:2008/10/6 2:07:00 -- 做得不是很好: |
-- 作者:易服 -- 发布时间:2008/10/6 8:47:00 -- 肯定不会好东拼西凑知其然不知其所以然,请给优化一下? |
-- 作者:狐狸爸爸 -- 发布时间:2008/10/6 9:14:00 -- 其实专业报表并不复杂,只是相对繁琐而以,好好学习一下,将所有的例子,都自己动手做一次,你一定能够掌握。 |