Foxtable(狐表)用户栏目专家坐堂 → [求助]专业报表高度


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

主题:[求助]专业报表高度

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


加好友 发短信
等级:八尾狐 帖子:1816 积分:19334 威望:0 精华:0 注册:2013/4/10 14:38:00
[求助]专业报表高度  发帖心情 Post By:2020/7/21 14:33:00 [只看该作者]

每打印一次,高度就会高0.5MM左右,这个怎样处理

 


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

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


 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107805 积分:548376 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/7/21 14:36:00 [只看该作者]

贴出完整代码

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


加好友 发短信
等级:八尾狐 帖子:1816 积分:19334 威望:0 精华:0 注册:2013/4/10 14:38:00
  发帖心情 Post By:2020/7/21 14:43:00 [只看该作者]

'先检查送货明细有多少条记录,如果超过60条,就提示不能大于60.处理好后打印

Dim Rowsh As Row = Tables("送货主表").Current

Dim shdh As String = Rowsh("送货单号") '取得送货单号

' 取得客户产品地址
Dim dress As String
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "s elect {产品}.地址 from {送货主表} inner join {产品} on {送货主表}.款号={产品}.款号 where {送货主表}.送货单号='" & shdh & "'"
dress = cmd.ExecuteScalar()
'MessageBox.show("地址是  " & dress)

Dim tb As Table = Tables("送货主表.送货明细")
Dim xl As Integer = Tb.Rows.count
If xl > 60 Then
    MessageBox.show("送货单不能打印大于60行的送货明细,请把送货单分几单处理再打印")
    'Return
Else
   
    Dim doc As New PrintDoc() '定义一个报表
    doc.PageSetting.Width = 130 '纸张宽度为100毫米
    doc.PageSetting.Height = 190 '纸张高度为191毫米
    Doc.PageSetting.LeftMargin = 5 '设置左边距
    Doc.PageSetting.RightMargin = 5 '设置右边距
    Doc.PageSetting.TopMargin = 5 '设置上边距
    Doc.PageSetting.BottomMargin = 5 '设置下边距
   
    '页眉,按需要增加'
    'Dim rtx As prt.rendertext '定义页眉的文本对象
    'rtx = New prt.RenderText '设置文本对象的内容
    'rtx.Text = "第[PageNo]页,共[PageCount]页" '设置文本内容
    'rtx.Style.TextAlignHorz = prt.AlignHorzEnum.Right '靠右对齐
    'rtx.Style.Borders.Bottom = New prt.LineDef(0.3, Color.Green) '设置底边框
    'rtx.Style.Padding.Bottom = 0.5 '底端内容缩进0.5毫米
    'rtx.Style.FontSize = 8 '字体大小为8磅
    'Doc.PageHeader = rtx '作为页眉使用
   
   
   
   
    Dim rt As New prt.RenderTable() '定义一个表格对象
    doc.Body.Children.Add(rt) '将表格对象加入到报表中
    rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
    rt.Width = 120 '表宽为150毫米
    rt.Height = 170 '表高为150毫米
    rt.Rows.Count = 25 '设置行数
    rt.Cols.Count = 8 '设置列数
   
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
   
    rt.Rows(0).Height = 12 '标题行高
    rt.Cells(0,0).SpanCols = 8 '合拼表头
    rt.cells(0,0).text = "胸围制衣厂送货单"
    rt.cells(0,0).Style.Font = New Font("宋体", 18, FontStyle.Bold) '设置字体
    rt.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第一行表格线
    rt.Rows(0).Style.Borders.Bottom = New prt.Linedef '增加第一行底线
   
   
    'Dim Rowsh As Row = Tables("送货主表").Current 在最上面声明
   
    rt.Rows(6).Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Rows(6).Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Cells(1,1).SpanCols = 4
    rt.Cells(1,6).SpanCols = 2
    rt.cells(1,0).text = "地    址"
    rt.cells(1,1).text = "大道26号三楼"
    rt.cells(1,5).text = "单号"
    rt.cells(1,6).text = Rowsh("送货单号")
   
   
    rt.Cells(2,1).SpanCols = 4
    rt.Cells(2,6).SpanCols = 2
    rt.cells(2,0).text = "手    机"
    rt.cells(2,1).text = "34938"
    rt.cells(2,5).text = "合同号"
    rt.cells(2,6).text = Rowsh("合同号")
   
    rt.Cells(3,1).SpanCols = 4
    rt.Cells(3,6).SpanCols = 2
    rt.cells(3,0).text = "收货单位"
    rt.cells(3,1).text = rowsh("客户")
    rt.cells(3,5).text = "款号"
    rt.cells(3,6).text = rowsh("款号")
   
    rt.Cells(4,1).SpanCols = 4
    rt.Cells(4,6).SpanCols = 2
    rt.cells(4,0).text = "收货地址"
    rt.cells(4,1).text = dress
    rt.cells(4,5).text = "颜色"
    rt.cells(4,6).text = rowsh("颜色")
   
   
    rt.Cells(5,1).SpanCols = 4
    rt.Cells(5,6).SpanCols = 2
    rt.cells(5,5).text = "日期"
    rt.cells(5,6).text = rowsh("送货日期")
   
   
   
   
   
   
   
    rt.Cells(6,0).text = "尺码"
    rt.Cells(6,1).text = "件数"
   
    rt.Cells(6,2).text = "尺码"
    rt.Cells(6,3).text = "件数"
   
    rt.Cells(6,4).text = "尺码"
    rt.Cells(6,5).text = "件数"
   
    rt.Cells(6,6).text = "尺码"
    rt.Cells(6,7).text = "件数"
   
   
   
    'Dim tb As Table = Tables("送货主表.送货明细")
    'Dim xl As Integer = Tb.Rows.count
   
    For c As Integer = 0 To 3
        For r As Integer = 7 To 21
            If c*15+r-7 >= xl Then
                Exit For
            End If
           
            'rt.cells(c*15+j-7,c*2).text = tb.rows(c*15+j-7)("款号")
            'rt.cells(c*15+j-7,c*2+1).text = tb.rows(c*15+j-7)("送货数量")
            rt.cells(r,C * 2).text = tb.rows(c*15+r-7)("款号")
            rt.cells(r,c*2).Style.TextAlignHorz = prt.AlignHorzEnum.Right
            rt.cells(r,c * 2 + 1).text = tb.rows(C*15+r-7)("送货数量")
           
        Next
       
    Next
   
   
    rt.Rows(23).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第23行表格线
   
    Dim i As Integer
    For i = 0 To 7
        rt.cells(23,i).Style.Borders.All = New prt.LineDef("0mm", Color.white)
    Next
    rt.Rows(23).Style.Borders.Top = New prt.Linedef
   
    rt.Rows(24).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第23行表格线
   
   
    For i = 0 To 7
        rt.cells(24,i).Style.Borders.All = New prt.LineDef("0mm", Color.white)
    Next
   
    rt.Rows(22).Height = 20 '标题行高
    rt.cells(22,0).text = "备注"
    rt.Cells(22,1).SpanCols = 7
    Dim ss As Integer
    ss = tb.Compute("sum(送货数量)")
    'MessageBox.show(ss)
    'rt.cells(22,1).text = "合计  " & ss & "   件"
    rt.cells(22,1).text = "合计 " & Rowsh("包数") & " 包" & "--共计 " & ss & " 件    -- " & Rowsh("备注")
   
   
    rt.cells(22,1).Style.TextAlignHorz = prt.AlignHorzEnum.Left
    rt.cells(22,1).Style.TextAlignVert = prt.AlignVertEnum.Top
   
   
    rt.cells(23,0).text = "收货单位"
    rt.cells(24,0).text = "及经手人"
    rt.Cells(23,1).SpanCols = 3
    rt.cells(23,1).SpanRows = 2
    rt.cells(23,1).text = "(盖章)"
   
    rt.cells(23,4).text = "送货单位"
    rt.cells(24,4).text = "及经手人"
    rt.Cells(23,5).SpanCols = 3
    rt.cells(23,5).SpanRows = 2
    rt.cells(23,5).text = "(盖章)"
    Doc.PrinterName = "EPSON LQ-615KII ESC/P2"

    doc.Preview() '预览
End If


 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107805 积分:548376 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/7/21 15:00:00 [只看该作者]

意思是每次点击调用代码打印一张,就有偏差?而不是一次打印多张纸的时候有偏差?

如果是前者应该是打印机走纸设置的问题吧

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


加好友 发短信
等级:八尾狐 帖子:1816 积分:19334 威望:0 精华:0 注册:2013/4/10 14:38:00
  发帖心情 Post By:2020/7/21 15:16:00 [只看该作者]

如果每次打完后撕断,再回位打印,就没有问题,如果连续打印,位置每次会向后偏移约0.5MM

 

 


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

 回到顶部
帅哥,在线噢!
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107805 积分:548376 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/7/21 15:33:00 [只看该作者]

把系统默认纸张和代码里的纸张高度都同步设置一样的值,都设置大一点测试

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


加好友 发短信
等级:八尾狐 帖子:1816 积分:19334 威望:0 精华:0 注册:2013/4/10 14:38:00
  发帖心情 Post By:2020/7/21 15:49:00 [只看该作者]

试过了

 


 回到顶部
帅哥,在线噢!
有点蓝
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107805 积分:548376 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/7/21 15:55:00 [只看该作者]

大1、2、3、......10,20毫米分别测试,效果都一样?

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


加好友 发短信
等级:八尾狐 帖子:1816 积分:19334 威望:0 精华:0 注册:2013/4/10 14:38:00
  发帖心情 Post By:2020/7/21 16:16:00 [只看该作者]

都是0.5步进,我再试下

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


加好友 发短信
等级:二尾狐 帖子:513 积分:4618 威望:0 精华:0 注册:2016/12/17 11:51:00
  发帖心情 Post By:2020/7/21 16:17:00 [只看该作者]

连纸纸张尺寸一定要手工量,再自定义到系统纸张里

 回到顶部
总数 11 1 2 下一页