以文本方式查看主题

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

--  作者:lshshlxsh
--  发布时间:2020/6/15 9:38:00
--  报表打印

麻烦老师帮忙看一下 预览是正确的   打印机纸张变大之后 内容也跟着变大了

 

Dim r As Row =Tables("物料表").Current
Dim rg As prt.RenderGraphics
Dim Bar As New BarCodeBuilder
Bar.Symbology = Barpro.Symbology.QRCode
Bar.Code = "http://www.baidu.com"
Bar.QuietZoneWidth = 2
Bar.SaveImage(ProjectPath & "Reports\\xsd" & r("物料代码") & ".jpg"  )
Dim doc As New PrintDoc \'定义一个报表
doc.PageSetting.Width = 100 \'纸张宽度为100毫米
doc.PageSetting.Height = 60 \'纸张高度为120毫米

rg = new prt.RenderGraphics
bar.DrawOnCanvas(rg.Graphics,0,0,1)
rg.Style.Spacing.Top = 3

Dim rep As New prt.RenderEmpty \'定义一个新的空对象
rep.BreakBefore = prt.BreakEnum.Page \'打印前换页
doc.Body.Children.Add(rep ) \'加入到报表中
Dim rt As New prt.RenderTable() \'定义一个表格对象
rt.Style.Font = New Font("微软雅黑",8) \'设置文本对象的字体
rt.Style.TextAlignHorz = prt.AlignHorzEnum.left
rt.Style.TextAlignVert =  prt.AlignHorzEnum.Center
rt.Style.Borders.All = New  prt.Linedef(0.5, Color.black)
rt.Cols(0).Width =2
rt.Cols(4).Width =2
rt.Cols(6).Width =2
rt.Cols(1).Width =15
rt.Height =55
For i As Integer = 1 To 5
    rt.Cells(0,i).Style.Borders.Bottom  =New prt.Linedef(0.1, Color.Gray , DashStyle.Solid ) \'设置底边框
Next

For i As Integer = 1 To 5
    For J As Integer =1 To 3
        rt.Cells(i,j).Style.Borders.Bottom  =New prt.Linedef(0.1, Color.Gray , DashStyle.Solid ) \'设置底边框
    Next
Next

For i As Integer = 0 To 6
    rt.Cells(i,2).Style.Font =New Font("微软雅黑", 8, FontStyle.Bold) \'设置字体
Next
rt.Cells(0,4).Style.Font =New Font("微软雅黑", 8, FontStyle.Bold) \'设置字体

rt.Cells(0,1).Text = "物料编码"
rt.Cells(0,2).Text =r("物料代码")
rt.Cells(0,3).Style.TextAlignHorz = prt.AlignHorzEnum.right
rt.Cells(0,3).Text =" 订单号"
rt.Cells(0,4).Text =""
rt.Cells(0,4).SpanCols =2
rt.Cells(1,1).Text = "物料名称"
rt.Cells(1,2).Text =r("物料名称")
rt.Cells(1,2).SpanCols =2
rt.Cells(2,1).Text = "物料尺寸"
rt.Cells(2,2).Text =r("规格型号")
rt.Cells(2,2).SpanCols =2
rt.Cells(2,5).Text =  ProjectPath & "Reports\\xsd" & r("物料代码") & ".jpg"
rt.Cells(2,5).SpanRows =4
rt.Cells(2,5).RenderObject =rg
rt.Cells(3,1).Text = "定制产品"

Dim dz As String

rt.Cells(3,2).Text =dz
rt.Cells(3,2).SpanCols =2

rt.Cells(4,1).Text = "包装说明"
rt.Cells(4,2).Text = ""
rt.Cells(4,2).SpanCols =2

rt.Cells(5,1).Text = "进仓编号"
rt.Cells(5,2).Text =""
rt.Cells(5,2).SpanCols =2

rt.Cells(6,1).Text = "常规效果"
rt.Cells(6,2).Text =r("效果")
rt.Cells(6,2).SpanCols =5

doc.Body.Children.Add(rt)

Doc.PageSetting.LeftMargin = 2 \'设置左边距
Doc.PageSetting.RightMargin = 2 \'设置右边距
Doc.PageSetting.TopMargin = 2 \'设置上边距
Doc.PageSetting.BottomMargin =2  \'设置下边距

Doc.Preview

 

 

 

 

 

 

 

 

 

 


--  作者:有点蓝
--  发布时间:2020/6/15 9:52:00
--  
指定表格宽度

Dim rt As New prt.RenderTable() \'定义一个表格对象
rt.Width = 96

--  作者:lshshlxsh
--  发布时间:2020/6/15 10:30:00
--  
谢谢老师  如果是 240 * 140的纸张 这个设置了 但是会出现空白页   这个要怎么解决?
--  作者:有点蓝
--  发布时间:2020/6/15 10:43:00
--  
截图并贴出代码说明