以文本方式查看主题

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

--  作者:与伊相伴
--  发布时间:2012/7/25 21:53:00
--  专业报表的分页

如何在专业报表中设置,当表中有很多数据时,以每页显示4款产品,都有表上面的说明,每页最后一行都是显示需要签字确认的行


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


--  作者:与伊相伴
--  发布时间:2012/7/26 8:41:00
--  

那是Excel报表,我要用的是专业报表的设置哦...


--  作者:blackzhu
--  发布时间:2012/7/26 8:45:00
--  
其实这个用excel报表比专业报表简单.
--  作者:blackzhu
--  发布时间:2012/7/26 8:50:00
--  
For r As integer = 0 To Rows.Count-1   改成   For r As integer = 0 To 3   试试


因为没有你的代码,猜的.

--  作者:与伊相伴
--  发布时间:2012/7/26 9:17:00
--  专业报表打印
其实每种类型都它的好处,Excel的需要导出,用专业报表的话不能再修改,可以直接打印了,还有掌握了几种之后,可以选择使用自己喜欢和擅长的那是多么好的事,希望得到指点../
--  作者:与伊相伴
--  发布时间:2012/7/26 9:20:00
--  专业报表打印

谢谢你能中百忙之中抽出时间来看我的问题,如果你可以再抽一点时间的话,我在呈上代码后,能否再帮我看一下,哪里出的问题,先谢了

\'\'\'公司信息表
If DataTables.Contains("gslb_chd_cx") = False Then
    Dim q As new QueryBuilder
    q.C
    q.TableName = "gslb_chd_cx"
    q.SelectString = "Select id,gsqc,gsjc,gsdz,dhhm,czhm,wz,yx,bhqz,qyzt from sy_gslb"
    q.Build
End If
Dim r0 As Row = Tables("gslb_chd_cx").Rows(0)
Dim s As String
If r0("gsqc") <> Nothing Then
    s = Trim(r0("gsqc"))
End If

Dim doc As New PrintDoc \'定义一个新报表
doc.AutoRotate = False \'禁止自动旋转打印内容
doc.PageSetting.Width = 297 \'纸张宽度
doc.PageSetting.Height =210 \'纸张高度
Doc.PageSetting.LeftMargin = 5 \'设置左边距
Doc.PageSetting.RightMargin = 5 \'设置右边距
Doc.PageSetting.TopMargin = 3 \'设置上边距
Doc.PageSetting.BottomMargin = 1 \'设置下边距

\'\'\'\'++++++++++++++++++\'\'\'\'定义表头及表尾文字
Dim cmd As new SQLCommand
cmd.C

Dim dr As Row = Args(2)
Dim tb As Table = Args(3)

If Args(1) <> "重打" Then
    cmd.CommandText = "update sc_ddzb set dy = 1 where scph = \'" & Trim(dr("订单编号")) & "\'"
    cmd.ExecuteScalar()
End If

Dim ir As Integer
If (tb.Rows.Count Mod 5) = 0 Then
    ir = tb.Rows.Count / 5
Else
    ir = Cint(tb.Rows.Count / 5) + 1
End If
\'MessageBox.Show(1 + i)
\'Dim ra As New prt.RenderArea \'定义一个容器
\'ra.SplitVertBehavior = prt.SplitBehaviorEnum.Never  \'禁止容器因为分页而被垂直分割

\'For i As Integer = 0 To ir - 1
Dim rt1,rt2,rt3,rt4,rt5,rt6,rt7,rt8 As New prt.RenderText \'定义文本对象
\'For i As Integer = tb.TopRow To tb.BottomRow
rt1.Text = s & "生产总单"
rt1.Style.Font =  New Font("华文细黑", 24 )
rt1.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'居中
rt1.Style.FontBold = True \'加粗
rt1.y = 14  \'指定垂直位置
doc.Body.Children.Add(rt1)
\'ra.Children.Add(rt1)

rt2.Text = "客户名称:" & Trim(dr("客户名称"))
rt2.Style.Font =  New Font("宋体", 12 ) \',
rt2.x = 8 \'指定水位位置
rt2.y = 27 \'指定垂直位置
doc.Body.Children.Add(rt2)
\'ra.Children.Add(rt2)
\'\'\'\'\'
rt3.Text = "接单日期:" & dr("接单日期") & "                        " & "下单日期:" & Trim(Format(dr("下单日期"),"yyyy-MM-dd"))
rt3.Style.Font =  New Font("宋体", 12 ) \',
rt3.X = 100 \'指定水平位置
rt3.y = 27 \'指定垂直位置
doc.Body.Children.Add(rt3)
\'ra.Children.Add(rt3)
\'\'\'\'\'
rt4.Text = "订单编号:" & Trim(dr("订单编号"))
rt4.Style.Font =  New Font("宋体", 12 ) \',
rt4.x = 8
rt4.y = 33 \'指定垂直位置
doc.Body.Children.Add(rt4)
\'ra.Children.Add(rt4)

rt5.Text = "交货日期:" & Trim(dr("交货日期")) & "                       " & "操 作 人:" & Trim(dr("操作员"))
rt5.Style.Font =  New Font("宋体", 12) \',
rt5.X = 100 \'指定水平位置
rt5.y = 33 \'指定垂直位置
doc.Body.Children.Add(rt5)
\'ra.Children.Add(rt5)

\'rt6.Text = "总共" & ir - 1 & "页 第" & i +1 & "页"
\'rt6.Style.Font =  New Font("宋体", 10) \',
\'rt6.X = 258 \'指定水平位置
\'rt6.y = 38 \'指定垂直位置
\'doc.Body.Children.Add(rt6)
\'ra.Children.Add(rt6)

\'\'\'\'\'
Dim rt As New prt.RenderTable \'定义一个新表格
rt.X = 4 \'指定水平位置
rt.y = 42 \'指定垂直位

Dim ColNames As String() = New String(){ "序号","产品编号", "产品名称", "图片","工艺","效果要求","包装要求","数量","单位" }
\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'设置列宽
rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和
rt.Cols(0).Width = 12  \'产品编号
rt.Cols(1).Width = 22  \'产品编号
rt.Cols(2).Width = 22  \'产品名称
rt.Cols(3).Width = 46  \'图片
rt.Cols(4).Width = 36  \'工艺
rt.Cols(5).Width = 80   \'效果要求
rt.Cols(6).Width = 28   \'包装要求
rt.Cols(7).Width = 20   \'数量
rt.Cols(8).Width = 10    \'单位

\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'填入内容
For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内容
    rt.Cells(0,c).Text = ColNames(c) \'列名作为标题
    rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中
    If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then \'如果是数值或日期列
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右
    Else
        rt.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'生产批号居中
        rt.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'生产批号居中
        rt.Cols(6).Style.TextAlignHorz = prt.AlignHorzEnum.left \'计价居中
        rt.Cols(6).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'单位居中
        rt.Cols(8).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'单位居中
    End If
    For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
        rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
       
        cmd.CommandText = "select tp from yp_cptp where cpbh = \'" & tb.Rows(r)(ColNames(1)) & "\'"
        If cmd.ExecuteScalar() IsNot Nothing Then
            Dim imageByte() As Byte = cmd.ExecuteScalar()    \'查询数据,并存入字节数组
            Dim ms As New IO.MemoryStream(imageByte)         \'将字节数组转换为二进制流
            Dim image As Image = Image.FromStream(ms)        \'将二进制流转换为图片
            Dim rm As New prt.RenderImage() \'定义一个图片对象
            rm.Image = image ‘图片
            rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center \'图片水平居中
            rm.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center \'图片垂直居中
            rm.Style.ImageAlign.KeepAspectRatio = True
            rm.Height = 45
            rm.Width = 45
            rt.Cells(r + 1, 3).RenderObject = rm
        Else
            rt.Cells(r + 1, 3).RenderObject = Nothing
        End If
    Next
Next

\'\'\'\'\'\'\'\'\'\'\'\'以下代码确保数据行数为5行
For r1 As Integer = tb.Rows.Count + 1 To 5 \'开始填入该列内容
    For c As Integer = 0 To ColNames.Length - 1  \'逐列设置和填入内容
        rt.Cells(r1, c).Text = ""
    Next
Next
For r2 As Integer = 0 To rt.Rows.Count -1
    rt.Rows(r2).Height = 33.5 \'行高
    rt.Rows(r2).Style.TextAlignVert = prt.AlignVertEnum.Center \'文字垂直居中
    rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
Next
\'\'\'\'\'\'\'\'\'\'\'
rt.Rows(0).Height = 10  \'设置表头行高
If tb.Rows.Count >= 4 Then
    rt.Rows(tb.Rows.Count+1).Height = 13  \'设置表底行高
    rt.Cells(tb.Rows.Count+1,0).SpanCols = 9 \'第7行第1个单元格向右合并5列
    rt.Cells(tb.Rows.Count+1,0).text = "  生产经理:                                                                                                                          " & _
    "下单员:" & Vars("UserName")
    rt.Cells(tb.Rows.Count+1,0).Style.TextAlignHorz = prt.AlignHorzEnum.left
Else
    rt.Cells(5,0).text = "  生产经理:                                                                                                                          " & _
    "   下单员:" & Vars("UserName")
    rt.Cells(5,0).SpanCols = 9 \'第7行第1个单元格向右合并5列
    rt.Rows(5).Height = 13  \'设置表底行高
    rt.Cells(5,0).Style.TextAlignHorz = prt.AlignHorzEnum.left
End If
rt.Rows(tb.Rows.Count+1).Style.TextAlignVert = prt.AlignVertEnum.Center \'文字垂直居中
rt.Rows(tb.Rows.Count+1).Style.TextAlignHorz = prt.AlignHorzEnum.Center

rt.Style.GridLines.All = New Prt.LineDef(0.2, Color.Black) \'所有边框
rt.Style.GridLines.Bottom = New Prt.LineDef(0.5, Color.Black) \'下边框
rt.Style.GridLines.Left = New Prt.LineDef(0.5, Color.Black) \'左边框
rt.Style.GridLines.Right = New Prt.LineDef(0.5, Color.Black) \'右边框
rt.Style.GridLines.Top = New Prt.LineDef(0.5, Color.Black) \'上边框

\'rt.BreakAfter = prt.BreakEnum.page   \'打印之后另起一栏
\'rt.BreakAfter = prt.BreakEnum.Page
\'ra.Children.Add(rt)
doc.Body.Children.Add(rt) \'将文本对象加入到报表

\'Next

doc.Preview()
\'doc.Print()