以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]专业报表行高不同  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=33613)

--  作者:bohe
--  发布时间:2013/5/21 16:57:00
--  [求助]专业报表行高不同


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

复制帮助中的代码,修改了一下

Dim doc As New PrintDoc \'定义一个新报表
Dim rt As prt.RenderTable \'定义一个新表格
Dim tb As Table = Tables("信息")
Dim rx As prt.RenderText
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tb.DataTable.GetUniqueValues("","班级")
doc.PageSetting.PaperKind = 9
Doc.PageSetting.TopMargin = 5 \'设置上边距
Doc.PageSetting.BottomMargin = 8
For Each Region As String In Regions
    rx = New prt.RenderText
   rx.BreakBefore = prt.BreakEnum.Page \'打
    rx.Style.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "高二(" & Region & ")班"
    doc.Body.Children.Add(rx)
rt = New prt.RenderTable
rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font
    Rows = tb.DataTable.Select("[班级] = \'" & Region & "\'")
    For c As Integer = 0 To tb.Cols.Count - 1
        rt.Cells(0,c).Text = tb.Cols(c).Name
        rt.Cols(c).Width = tb.Cols(c).PrintWidth
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.center 

        rt.Cols(c).Style.TextAlignVert = prt.AlignVertEnum.Center
        For r As Integer = 0 To Rows.Count -1
    rt.Rows(r).Height = 8
            rt.Cells(r + 1, c).Text = rows(r)(tb.Cols(c).Name)
        Next
    Next
   rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头
doc.Body.Children.Add(rt) \'将表格加入到报表
Next
doc.Preview()

[此贴子已经被作者于2013-5-21 18:01:02编辑过]

--  作者:bohe
--  发布时间:2013/5/21 16:58:00
--  
每班最后一行行高变小了
--  作者:狐狸爸爸
--  发布时间:2013/5/21 17:59:00
--  
你得提供表给大家测试
--  作者:bohe
--  发布时间:2013/5/21 18:07:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:信息会考.table


--  作者:don
--  发布时间:2013/5/22 15:44:00
--  
幫頂,確如所言.
--  作者:狐狸爸爸
--  发布时间:2013/5/22 17:04:00
--  

代码逻辑问题:

 

Dim doc As New PrintDoc \'定义一个新报表
Dim rt As prt.RenderTable \'定义一个新表格
Dim tb As Table = Tables("信息")
Dim rx As prt.RenderText
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tb.DataTable.GetUniqueValues("","班级")
doc.PageSetting.PaperKind = 9
Doc.PageSetting.TopMargin = 5 \'设置上边距
Doc.PageSetting.BottomMargin = 8
For Each Region As String In Regions
    rx = New prt.RenderText
    rx.BreakBefore = prt.BreakEnum.Page \'打
    rx.Style.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "高二(" & Region & ")班"
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和
    rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页
    rt.Style.Font = tb.Font
    Rows = tb.DataTable.Select("[班级] = \'" & Region & "\'")
    For c As Integer = 0 To tb.Cols.Count - 1
        rt.Cells(0,c).Text = tb.Cols(c).Name
        rt.Cols(c).Width = tb.Cols(c).PrintWidth
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.center \'数据水平居中
        rt.Cols(c).Style.TextAlignVert = prt.AlignVertEnum.Center
        For r As Integer = 0 To Rows.Count -1
           
            rt.Cells(r + 1, c).Text = rows(r)(tb.Cols(c).Name)
        Next
    Next
    For r As Integer = 0 To rt.Rows.Count -1
        rt.Rows(r).Height = 8
    Next
   
    \'    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头
    doc.Body.Children.Add(rt) \'将表格加入到报表
Next
doc.Preview()