以文本方式查看主题

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

--  作者:cuicuibing
--  发布时间:2017/3/23 8:48:00
--  专业报表打印
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
Dim doc As New PrintDoc \'定义一个新报表

For Each r1 As Row In  Tables("样品派工单").GetCheckedRows
    Dim rx As prt.rendertext
    rx = New prt.RenderText
    rx.text = "样品派工单"
    rx.Style.FontBold = True \'字体加粗
    rx.Style.FontSize = 16 \'大体大小为16磅
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中排列
    rx.Style.Spacing.Bottom = 3 \'和下面的对象(表格)距离3毫米
    doc.Body.Children.Add(rx) \'加入到报表中
    rx = New prt.RenderText
    rx.Style.FontSize = 16
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 5
    rx.Text = "编号: " & r1("编号") & "   产品货号: " & r1("产品货号") &  "    数量: " & r1("数量")
    doc.Body.Children.Add(rx)

    Dim rt As New prt.RenderTable \'定义一个新表格
    cmd.CommandText = "S ELECT * From {样品派工明细} where 编号= \'"& r1("编号") &"\'"
    dt = cmd.ExecuteReader()
    Dim ColNames As String() = New String(){"部件名称", "材料名称", "规格","部件数量",“用量”,“单位”}

    这里代码应该如何写。



    rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never 
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线
    rt.CellStyle.Spacing.All = 1 \'内容距离网格线1毫米
    rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
    doc.Body.Children.Add(rt) 
       
    rx = New prt.RenderText
    rx.Style.FontSize = 16
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 5
    rx.Text = "下单人: " & r1("操作员")
    doc.Body.Children.Add(rx)


--  作者:有点蓝
--  发布时间:2017/3/23 8:52:00
--  
你要做什么功能?完成什么逻辑?
--  作者:有点色
--  发布时间:2017/3/23 9:18:00
--  

 做个实例上来,说明要做什么效果。

 

 


--  作者:cuicuibing
--  发布时间:2017/3/23 9:55:00
--  
版主,这里我后台数据打印,指定字段。  
标红字代码不会写。
Dim rt As New prt.RenderTable \'定义一个新表格
    cmd.CommandText = "S ELECT * From {样品派工明细} where 编号= \'"& r1("编号") &"\'"
    dt = cmd.ExecuteReader()
    Dim ColNames As String() = New String(){"部件名称", "材料名称", "规格","部件数量",“用量”,“单位”}

    这里代码应该如何写。

--  作者:有点色
--  发布时间:2017/3/23 10:01:00
--  
Dim drs As List(of DataRow) = dt.Select("")
For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内容
    rt.Cells(0,c).Text = ColNames(c) \'列名作为标题
    For r As Integer = 0 To drs.Count -1 \'开始填入该列内容
        rt.Cells(r + 1, c).Text = drs(r)(ColNames(c))
    Next
Next