Foxtable(狐表)用户栏目专家坐堂 → 凑成偶数页打印,并填充空白行


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

主题:凑成偶数页打印,并填充空白行

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


加好友 发短信
等级:二尾狐 帖子:568 积分:5458 威望:0 精华:0 注册:2018/11/6 10:54:00
凑成偶数页打印,并填充空白行  发帖心情 Post By:2023/5/13 16:53:00 [只看该作者]

如果总页数是单数,加空白页凑成双数页,并填充空白行,怎么改代码?
Dim doc As New PrintDoc
Dim 
tb As Table = Tables("订单")
Dim 
prs As Integer = 20 '每页20行
For 
p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1
    
Dim rt As New prt.RenderTable
    
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
    
rt.CellStyle.Spacing.All = 0.5
    For 
c As Integer = 0 To tb.Cols.Count - 1
        
rt.Cells(0,c).Text = tb.Cols(c).Name
    Next
    For 
r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
        For 
c As Integer = 0 To tb.Cols.Count - 1
            
rt.Cells(r - p * prs + 1c).Text = tb.rows(r)(c)
        Next
    Next
    If 
p = math.Ceiling(tb.Rows.Count / prs) - 1 '如果是最后一页
        For 
r As Integer = tb.Rows.Count To ( p + 1) * prs - '补空行
            
rt.Rows.Count = rt.Rows.Count + 1
            
rt.Rows(rt.Rows.count -1)(0).text = " "
        Next
    Else
        
rt.BreakAfter = prt.BreakEnum.Page '否则换页
    End If
    
doc.Body.Children.Add(rt)
Next

doc
.Preview()

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


加好友 发短信
等级:超级版主 帖子:110825 积分:564069 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/5/13 17:41:00 [只看该作者]

Dim doc As New PrintDoc
Dim tb As Table = Tables("订单")
Dim prs As Integer = 20 '每页20行
Dim cnt As Integer = math.Ceiling(tb.Rows.Count / prs)
Output.Show(cnt)
For p As Integer = 0 To cnt - 1
    Dim rt As New prt.RenderTable
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
    rt.CellStyle.Spacing.All = 0.5
    For c As Integer = 0 To tb.Cols.Count - 1
        rt.Cells(0, c).Text = tb.Cols(c).Name
    Next
    For r As Integer = p * prs To math.min(tb.Rows.Count - 1, ( p + 1) * prs - 1)
        For c As Integer = 0 To tb.Cols.Count - 1
            rt.Cells(r - p * prs + 1, c).Text = tb.rows(r)(c)
        Next
    Next
    If p = math.Ceiling(tb.Rows.Count / prs) - 1  Then'如果是最后一页
        For r As Integer = tb.Rows.Count To ( p + 1) * prs - 1 '补空行
            rt.Rows.Count = rt.Rows.Count + 1
            rt.Rows(rt.Rows.count - 1)(0).text = " "
        Next
    End If
    rt.BreakAfter = prt.BreakEnum.Page '否则换页
    doc.Body.Children.Add(rt)
Next
If cnt Mod 2 = 1 Then
    Dim rt As New prt.RenderTable
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
    rt.CellStyle.Spacing.All = 0.5
    For c As Integer = 0 To tb.Cols.Count - 1
        rt.Cells(0, c).Text = tb.Cols(c).Name
    Next
    For r As Integer = 1 To 20 '补空行
        rt.Rows.Count = rt.Rows.Count + 1
        rt.Rows(rt.Rows.count - 1)(0).text = " "
    Next
    doc.Body.Children.Add(rt)
End If 
doc.Preview()


 回到顶部