以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  统计打印  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=191901)

--  作者:wlj88868
--  发布时间:2024/5/14 17:59:00
--  统计打印

Dim doc As PrintDoc = e.Form.GernatePrintDoc()
doc.Preview()

这句代码是打印这个窗口的,

\'Dim grp As WinForm.table = e.Form.Controls("Table1")
\'Dim doc As PrintDoc = e.Form.GernatePrintDoc(grp)
\'doc.Preview()

这句代码会报错的,麻烦给给正常的代码谢谢


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

--  作者:有点蓝
--  发布时间:2024/5/14 20:14:00
--  
如果只打印表,建议使用这种:http://www.foxtable.com/webhelp/topics/1772.htm
--  作者:wlj88868
--  发布时间:2024/5/14 21:48:00
--  

Dim doc As New PrintDoc
Dim tb As Table = Tables("统计查询_Table1")
Dim prs As Integer = 40 \'每页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
        For r As Integer = p * prs To math.min(tb.Rows.Count - 1, ( p + 1) * prs - 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
        rt.BreakAfter = prt.BreakEnum.Page
    End If
    doc.Body.Children.Add(rt)
Next
doc.Preview()

 

老师刚刚我用这个方法实现了,,但是列宽要在在那个位置设置,,,还有隐藏的列不想打印,怎么设置,,给调整一下代码呗,谢谢


--  作者:有点蓝
--  发布时间:2024/5/14 22:26:00
--  
列宽参考:http://www.foxtable.com/webhelp/topics/1204.htm

    For c As Integer = 0 To tb.Cols.Count - 1
if tb.Cols(c).Visible = True
        rt.Cells(0, c).Text = tb.Cols(c).Name

--  作者:wlj88868
--  发布时间:2024/5/15 15:10:00
--  

老师你给的这句代码好像就是隐藏了数据,,格子还在,,页面左右上下间距是怎么设置的,麻烦再统计窗口的打印给调试一下,我学习学习

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:税票管理.rar


--  作者:有点蓝
--  发布时间:2024/5/15 15:36:00
--  
页边距参考:http://www.foxtable.com/webhelp/topics/1192.htm

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:税票管理.zip



--  作者:wlj88868
--  发布时间:2024/5/15 17:07:00
--  

Dim doc As New PrintDoc
Dim tb As Table = Tables("统计查询_Table1")
Dim prs As Integer = 38 \'每页20行
For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1
    Dim rt As New prt.RenderTable
    Dim rx As New prt.RenderText
    Dim ra As New prt.RenderArea \'定义一个容器
    ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never \'禁止容器因为分页而被垂直分割
    rx.text = "月统计奖励表"
    rx.Style.FontBold = True \'字体加粗
    rx.Style.FontSize = 16 \'大体大小为16磅
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中排列
    rx.Style.Spacing.Bottom = 3 \'和下面的对象(表格)距离3毫米
    ra.Children.Add(rx)

    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
    rt.CellStyle.Spacing.All = 0.5
    Doc.PageSetting.LeftMargin = 10 \'设置左边距
    Doc.PageSetting.RightMargin = 10 \'设置右边距
    Doc.PageSetting.TopMargin = 15 \'设置上边距
    Doc.PageSetting.BottomMargin = 15 \'设置下边距
    rt.Width = "Parent.Width" \'对象宽度等于页面宽度
    rt.Height = "Parent.Height" \'对象高度等于页面高度
    rt.Style.FontSize = 12 \'大体大小为16磅
    rt.Cols(0).Width = 60 \'设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列)
    rt.Cols(1).Width = 30
    rt.Cols(2).Width = 30
    Dim idx As Integer = 0
    For c As Integer = 0 To tb.Cols.Count - 1
        If tb.Cols(c).Visible = True Then
            rt.Cells(0, idx).Text = tb.Cols(c).Name
            For r As Integer = p * prs To math.min(tb.Rows.Count - 1, ( p + 1) * prs - 1)
                rt.Cells(r - p * prs + 1, idx).Text = tb.rows(r)(c)
            Next
            idx += 1
        End If
    Next
    If p < math.Ceiling(tb.Rows.Count / prs) - 1 Then
        rt.BreakAfter = prt.BreakEnum.Page
    End If
    ra.Children.Add(rt)
    Doc.Body.ChildRen.Add(ra)

Next
doc.Preview()

 

 

老师我加了个标题,,下面的表格不会显示了,,红色的改的,看不出哪里的毛病,,麻烦给看一下

 


--  作者:有点蓝
--  发布时间:2024/5/15 17:10:00
--  
http://www.foxtable.com/webhelp/topics/2735.htm
--  作者:有点蓝
--  发布时间:2024/5/15 17:21:00
--  
Dim doc As New PrintDoc
Doc.PageSetting.LeftMargin = 10 \'设置左边距
Doc.PageSetting.RightMargin = 10 \'设置右边距
Doc.PageSetting.TopMargin = 15 \'设置上边距
Doc.PageSetting.BottomMargin = 15 \'设置下边距
Dim tb As Table = Tables("统计查询_Table1")
Dim prs As Integer = 38 \'每页20行
For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1
    Dim rt As New prt.RenderTable
    Dim rx As New prt.RenderText
    Dim ra As New prt.RenderArea \'定义一个容器
\'    ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never \'禁止容器因为分页而被垂直分割
    rx.text = "月统计奖励表"
    rx.Style.FontBold = True \'字体加粗
    rx.Style.FontSize = 16 \'大体大小为16磅
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中排列
    rx.Style.Spacing.Bottom = 3 \'和下面的对象(表格)距离3毫米
\'    ra.Children.Add(rx)
Doc.Body.ChildRen.Add(rx)
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
    rt.CellStyle.Spacing.All = 0.5
    rt.Width = "Parent.Width" \'对象宽度等于页面宽度
    rt.Height = "Parent.Height - Prev.Height" \'对象高度等于页面高度
    rt.Style.FontSize = 12 \'大体大小为16磅
    rt.Cols(0).Width = 60 \'设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列)
    rt.Cols(1).Width = 30
    rt.Cols(2).Width = 30
    Dim idx As Integer = 0
    For c As Integer = 0 To tb.Cols.Count - 1
        If tb.Cols(c).Visible = True Then
            rt.Cells(0, idx).Text = tb.Cols(c).Name
            For r As Integer = p * prs To math.min(tb.Rows.Count - 1, ( p + 1) * prs - 1)
                rt.Cells(r - p * prs + 1, idx).Text = tb.rows(r)(c)
            Next
            idx += 1
        End If
    Next
    If p < math.Ceiling(tb.Rows.Count / prs) - 1 Then
        rt.BreakAfter = prt.BreakEnum.Page
    End If
\'    ra.Children.Add(rt)
    Doc.Body.ChildRen.Add(rt)
Next
doc.Preview()