Foxtable(狐表)用户栏目专家坐堂 → [求助]专业报表显示列标题


  共有11566人关注过本帖树形打印复制链接

主题:[求助]专业报表显示列标题

帅哥哟,离线,有人找我吗?
易服
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:787 积分:6349 威望:0 精华:0 注册:2008/9/1 8:26:00
[求助]专业报表显示列标题  发帖心情 Post By:2011/3/3 12:09:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:2011-3-3 12-00-05.png
图片点击可在新窗口打开查看

 

Dim Filter As String
Dim cmb As WinForm.ComboBox=e.Form.Controls("ComboBox1")
If cmb.Value IsNot Nothing Then
    If Filter > "" Then
        Filter = Filter & " And "
    End If
    Filter = Filter & "乡名= '" & cmb.Value & "'"
End If

Dim dt As DataTable
Dim g As New CrossTableBuilder("后台统计1", DataTables("申请表"),Filter)
If cmb.Value  IsNot Nothing Then
    g.HGroups.AddDef("村名")
Else
    g.HGroups.AddDef("乡名")
End If
If e.Form.Controls("RadioButton2").Checked Then
    g.VGroups.AddDef("登记权利")
Else
    g.VGroups.AddDef("林种")
End If
g.Totals.AddDef("面积")
g.HorizontalTotal = True
g.VerticalTotal = True
g.FromServer = True  '后台
dt = g.Build(True)

Dim doc As New PrintDoc
Dim rt As New prt.RenderTable
Dim rs As New prt.RenderText()
rt.Width = "Parent.Width"
rt.Style.Spacing.Top = 4 '表格和前面对象的垂直间隔为4毫米
rs.Text = "分乡登记权利(林种)面积统计表"
rs.Style.Font = New Font("宋体",18,FontStyle.Bold)
rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center '文本内容水平居中
Doc.PageHeader = rs '作为页眉使用 '设置页眉

Dim rt1 As prt.RenderText '定义一个文本对象
rt1 = New prt.RenderText '设置文本对象的内容
rt1.Text = "单位:亩.株.块" '设置文本内容
rt1.Style.TextAlignHorz = prt.AlignHorzEnum.Right '靠右对齐
rt1.Style.Borders.Bottom = New prt.LineDef(0.3, Color.Green) '设置底边框
rt1.Style.Padding.Bottom = 0.5 '底端内容缩进0.5毫米
rt1.Style.FontSize = 10 '字体大小为8磅
doc.Body.Children.Add(rt1) '将文本对象加入到表格中

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

Dim Count As Integer = 0
For Each Col AS DataCol In Dt.DataCols
    rt.Cells(0,Count).Text = Col.Name
    For r As Integer = 0 To dt.DataRows.Count - 1
        rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name)
    Next
    Count = Count + 1
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 1
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
doc.Body.Children.Add(rt)
doc.Preview()


 回到顶部
帅哥哟,离线,有人找我吗?
lihe60
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:6842 积分:43288 威望:0 精华:0 注册:2009/3/2 14:07:00
  发帖心情 Post By:2011/3/3 12:19:00 [只看该作者]

狐表的专业报表太烦琐,能不能简单点。


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251054 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2011/3/3 12:31:00 [只看该作者]

呵呵,专业报表非常简单,搭积木而已。

 

只是楼主不怎么去理解代码,总是硬套,做不到灵活运用。

Col有两个属性,Name返回名称,Caption返回标题,随意将代码中的Name改为Caption即可:

 

For Each Col AS DataCol In Dt.DataCols
    rt.Cells(0,Count).Text = Col.Caption
    For r As Integer = 0 To dt.DataRows.Count - 1
        rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name)
    Next
    Count = Count + 1
Next


 回到顶部