Rss & SiteMap

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

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

标题:[求助]专业报表代码报错

1楼
易服 发表于:2008/10/3 0:23:00
Dim doc As New PrintDoc '定义一个新报表
Dim rt As New prt.RenderTable '定义一个新表格
Dim tb as Table = Tables("总览")
Dim ColNames As String() = New String(){"村名", "小班号", "图幅号","农户数", "小地名", "权属","设计面积", "造林类别", "林种"}
rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
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
    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 = 0.5 '单元格内距设为0.5毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center '第一行内容垂直居中
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
doc.Body.Children.Add(rt) '将表格加入到报表
'如果需要分栏打印,请加上下面两行
'doc.Columns.Add()
'doc.Columns.Add()
doc.Preview()

      上面代码可以执行
Dim doc As New PrintDoc '定义一个新报表
Dim rt As New prt.RenderTable '定义一个新表格
Dim tb as Table = Tables("总览")
Dim ColNames As String() = New String(){"村名", "小班号", "图幅号","农户数", "小地名", "权属","设计面积", "造林类别", "林种",

"立地类型", "平均坡度", "坡向", "土层厚度", "生要树种", "次要树种", "混交比", "造林密度", "整地方式", "整地时间", "整地规格",

"造林方式", "造林时间", "抚育次数", "抚育时间", "种源类型", "需苗量", "苗木规格", "用工量", "投资概算"

 

}
rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
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
    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 = 0.5 '单元格内距设为0.5毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center '第一行内容垂直居中
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
doc.Body.Children.Add(rt) '将表格加入到报表
'如果需要分栏打印,请加上下面两行
'doc.Columns.Add()
'doc.Columns.Add()
doc.Preview()
       代码只增加

"立地类型", "平均坡度", "坡向", "土层厚度", "生要树种", "次要树种", "混交比", "造林密度", "整地方式", "整地时间", "整地规格",

"造林方式", "造林时间", "抚育次数", "抚育时间", "种源类型", "需苗量", "苗木规格", "用工量", "投资概算"

 

哪怕只增加一个列名称"立地类型"就报错

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

[此贴子已经被作者于2008-10-3 0:33:15编辑过]
2楼
czy 发表于:2008/10/3 12:04:00
Dim doc As New PrintDoc '定义一个新报表
Dim rt As New prt.RenderTable '定义一个新表格
Dim tb as Table = Tables("总览")
Dim ColNames As String() = New String(){"村名", "小班号", "图幅号","农户数", "小地名", "权属","设计面积", "造林类别", "林种","立地类型","平均坡度", "坡向", "土层厚度", "主要树种", "次要树种", "混交比", "造林密度", "整地方式", "整地时间", "整地规格", "造林方式", "造林时间", "抚育次数", "抚育时间", "种源类型", "需苗量", "苗木规格", "用工量", "投资概算" }
rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
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
    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 = 0.5 '单元格内距设为0.5毫米
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center '第一行内容垂直居中
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
doc.Body.Children.Add(rt) '将表格加入到报表
'如果需要分栏打印,请加上下面两行
'doc.Columns.Add()
'doc.Columns.Add()
doc.Preview()
[此贴子已经被作者于2008-10-3 12:05:46编辑过]
共2 条记录, 每页显示 10 条, 页签: [1]

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

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