以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  【专业报表】请问这种效果要如何加代码  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=29562)

--  作者:晕了快扶我
--  发布时间:2013/3/9 9:15:00
--  【专业报表】请问这种效果要如何加代码


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

这个是目前我做成的


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

这个是我想要的,每页固定15行,每行的行高固定为5.5毫米,如果不够15行,空行的的单元格边框如上图

下面是我的代码,求高手指点下如何加才能实现图2的效果

Dim Doc As New PrintDoc
Doc.PrinterName = "\\\\2011-20120311rn\\EPSON LQ-735K ESC/P2"
Doc.PageSetting.Width =218
Doc.PageSetting.Height =138
Doc.AutoRotate = False
Doc.PageSetting.TopMargin=4
Doc.PageSetting.BottomMargin=2
Doc.PageSetting.LeftMargin=5
Doc.PageSetting.RightMargin=0
Doc.PageSetting.Landscape = True
Doc.AutoRotate = False

Dim prs As Integer = 15   \'每页行数
Dim tb As Table = Tables("销售出库单主表.销售出库单子表")
Dim rx As New prt.RenderTable

rx.Width = 201
\'rx.Height = 96
rx.Style.Font = New Font("宋体", 9)
For p As Integer = 0 To Math.Ceiling((tb.Rows.Count / prs) - 1 )
    Dim hd As Integer = tb.HeaderRows
    Dim cnt As Integer
    tb.CreateReportHeader(rx,True)
    For c As Integer = 0 To tb.Cols.Count - 1
        If tb.Cols(c).Visible
            For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
                rx.Cells(r - p * prs + hd, cnt).Text = tb.rows(r)(c)
               
                rx.Cells(r - p * prs + hd,9).Text = "***"
                rx.Cells(r - p * prs + hd,8).Text = "***"
                rx.Cells(r - p * prs + hd,3).Style.TextAlignHorz =prt.AlignHorzEnum.Center
            Next
            If p < math.Ceiling(tb.Rows.Count / prs) - 1
                rx.BreakAfter = prt.BreakEnum.Page
            End If
            cnt = cnt+1
        End If
    Next
    rx.Cols.Insert(0) \'在左边插入一列,用于打印行号
    rx.Cols(0).Width = 8 \'设置行号列的宽度
    For i As Integer = 1 To rx.Rows.Count -hd
        rx.Cells(i+1,0).text = i \'逐行写入行号
    Next
Next
rx.Cells(0,0).SpanRows = 2\'第1行第1个单元格向下合并2行
rx.Cells(0,0).Text = "№"
rx.Cols(0).Style.TextAlignHorz= prt.AlignHorzEnum.Center
rx.Cols(0).Style.TextAlignVert =prt.AlignVertEnum.Center
rx.CellStyle.Spacing.All = 0.5 \'单元格内距设为0.5毫米
rx.Style.GridLines.All =  New prt.Linedef(0.1, Color.black)
doc.Body.Children.Add(rx) \'
doc.Preview()


--  作者:晕了快扶我
--  发布时间:2013/3/9 9:48:00
--  


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

好像效果不对呢..


--  作者:晕了快扶我
--  发布时间:2013/3/9 9:49:00
--  

第二行直接跑到第二页了


--  作者:晕了快扶我
--  发布时间:2013/3/9 9:52:00
--  


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

改了下行高,最后一行的底边又没有了


--  作者:晕了快扶我
--  发布时间:2013/3/9 9:55:00
--  

搞定了

For i As Integer = 1 To rx.Rows.Count -hd
        rx.Cells(i+1,0).text = i \'逐行写入行号
        icou = i +1
    Next

If icou < 15 Then
        rx.Cells(icou+1,0).text = "" \'逐行写入行号
        rx.Rows(icou+1).Height = (15-icou) * 5.5 \'第7行的高度为50毫米
    End If
指定行高要怎么设置呢?每一行的高度是5.5个毫米?


--  作者:晕了快扶我
--  发布时间:2013/3/9 9:59:00
--  
知道了..搞定,谢谢MUhua
--  作者:晕了快扶我
--  发布时间:2013/3/9 10:39:00
--  

还是把代码贴一下,方便有需要的后来者

Dim Doc As New PrintDoc
Doc.PrinterName = "\\\\2011-20120311rn\\EPSON LQ-735K ESC/P2"
Doc.PageSetting.Width =218
Doc.PageSetting.Height =138
Doc.AutoRotate = False
Doc.PageSetting.TopMargin=4
Doc.PageSetting.BottomMargin=2
Doc.PageSetting.LeftMargin=5
Doc.PageSetting.RightMargin=0
Doc.PageSetting.Landscape = True
Doc.AutoRotate = False

Dim prs As Integer = 15   \'每页行数

Dim icou As Integer
Dim tb As Table = Tables("销售出库单主表.销售出库单子表")
Dim rx As New prt.RenderTable

rx.Width = 201
rx.Height = 93.5
rx.Style.Font = New Font("宋体", 9)
For p As Integer = 0 To Math.Ceiling((tb.Rows.Count / prs) - 1 )
    Dim hd As Integer = tb.HeaderRows
    Dim cnt As Integer
    tb.CreateReportHeader(rx,True)
    For c As Integer = 0 To tb.Cols.Count - 1
        If tb.Cols(c).Visible
            For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
                rx.Cells(r - p * prs + hd, cnt).Text = tb.rows(r)(c)
               
                rx.Cells(r - p * prs + hd,9).Text = "***"
                rx.Cells(r - p * prs + hd,8).Text = "***"
                rx.Cells(r - p * prs + hd,3).Style.TextAlignHorz =prt.AlignHorzEnum.Center
            Next
            If p < math.Ceiling(tb.Rows.Count / prs) - 1
                rx.BreakAfter = prt.BreakEnum.Page
            End If
            cnt = cnt+1
        End If
    Next
    rx.Cols.Insert(0) \'在左边插入一列,用于打印行号
    rx.Cols(0).Width = 8 \'设置行号列的宽度
   
For i As Integer = 1 To rx.Rows.Count -hd
        rx.Cells(i+1,0).text = i \'逐行写入行号
        icou = i +1
    Next

If icou < 15 Then
        rx.Cells(icou+1,0).text = "" \'逐行写入行号
        rx.Rows(icou+1).Height = (15-icou+1) * 5.5 \'第7行的高度为50毫米
    End If


Next
rx.Cells(0,0).SpanRows = 2\'第1行第1个单元格向下合并2行
rx.Cells(0,0).Text = "№"
rx.Cols(0).Style.TextAlignHorz= prt.AlignHorzEnum.Center
rx.Cols(0).Style.TextAlignVert =prt.AlignVertEnum.Center
rx.CellStyle.Spacing.All = 0.5 \'单元格内距设为0.5毫米
rx.Style.GridLines.All =  New prt.Linedef(0.1, Color.black)
doc.Body.Children.Add(rx) \'
doc.Preview()

[此贴子已经被作者于2013-3-9 10:39:11编辑过]

--  作者:zerov
--  发布时间:2013/3/10 7:47:00
--  回复:(晕了快扶我)还是把代码贴一下,方便有需要的...
好人啊