Foxtable(狐表)用户栏目专家坐堂 → 老师,请问怎么能让打印的字体颜色和表中的颜色相同呢,或者动态的改变打印字体颜色


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

主题:老师,请问怎么能让打印的字体颜色和表中的颜色相同呢,或者动态的改变打印字体颜色

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/9 10:23:00 [显示全部帖子]

Dim doc As New PrintDoc '定义一个报表
Dim rt As New prt.RenderTable() '定义一个表格对象
Dim rx As New prt.RenderText() '定义一个文本对象
rt.Style.GridLines.All = New prt.Linedef


Dim tb As Table = Tables("选定排单明细")
Dim Rows As List(Of DataRow)


Dim dh As List(of String) = tb.DataTable.GetValues("排单单号")
Doc.PageSetting.LeftMargin = 10 '设置左边距
Doc.PageSetting.RightMargin = 10 '设置右边距
Doc.PageSetting.TopMargin = 10 '设置上边距
Doc.PageSetting.BottomMargin = 10 '设置下边距
Doc.PageSetting.Color = True


rt.CellStyle.Spacing.All = 2

 


For Each dh1 As String In dh
    Dim kh As List(Of String) = tb.DataTable.GetValues("物货其他","排单单号 = '"& dh1 & "'")
    rt.BreakAfter = prt.BreakEnum.Page
    rt = New prt.RenderTable
    rt.Cells(0,0).text = format(Date.Today().AddDays(1),"yyyy年MM月dd日") &"-" & "出货计划"
    rt.Cells(0,0).SpanCols = 10 '合并第一行全部单元格,用于显示主标题
    rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '主标题居中
    rt.Cells(0,0).Style.Font = New Font("微软雅黑", 16, FontStyle.Bold)
   
    rt.Cells(1,0).text = "                                                                                                                                                                   第[PageNo]页,共[PageCount]页"
    rt.Cells(1,0).SpanCols = 10 '合并第二行全部单元格,用于显示副标题
    rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Cells(1,0).Style.Font = New Font("微软雅黑", 10, FontStyle.Bold)
    rt.Rows(1).Height = 8
   
    rt.cells(2,0).text = "排单时间:" & Date.Today()
    rt.Cells(2,0).SpanCols = 2 '合并0-1,用于显示排单时间,车号,司机.时间点
    rt.cells(2,2).text = "排单单号:" & dh1
    rt.Cells(2,2).SpanCols = 3 '合并2-3,排单单号
    rt.cells(2,5).text = "车号:" & "15620"
    rt.Cells(2,5).SpanCols = 2
    rt.cells(2,7).text = "司机:" & "梁锋"
    rt.Cells(2,7).SpanCols = 2
    rt.cells(2,9).text = "早上"
    rt.Rows(2).Height = 10
    rt.RowGroups(0,3).Header = prt.TableHeaderEnum.All
    For p As Integer = 0 To 9
        rt.Cells(2,p).Style.Font = New Font("微软雅黑", 9, FontStyle.Bold)
    Next
    Doc.body.Children.Add(rt)
    For Each kh1 As String In kh
        Dim yz As String = format(tb.DataTable.Compute("sum(库存平方)","[物货其他] = '" & kh1 & "'and [排单单号] = '"& dh1 & "'and [品名] like '椰棕%'")/100,"0.00") & " m3"
        Dim E As String = Format(tb.DataTable.Compute("sum(库存平方)","[物货其他] = '" & kh1 & "'and [排单单号] = '"& dh1 & "'and [品名] like '3E棕%'")/100,"0.00") & " m3"
        Dim M As String = Format(tb.DataTable.Compute("sum(库存平方)","[物货其他] = '" & kh1 & "'and [排单单号] = '"& dh1 & "'and [品名] like '%棉'")/100,"0.00") & " m3"
        rt = New prt.RenderTable
       
        rx = New prt.RenderText
        rx.Style.FontSize = 10
        rx.Style.FontBold = True
        rx.Style.Spacing.All = 2
        rx.Text = "客户: " & kh1 & "椰棕:" & yz & "  " & "3E:" & E & "  " & "棉:" & M
        doc.Body.Children.Add(rx)
       
        Rows = tb.DataTable.Select("[物货其他] = '" & kh1 & "'and [排单单号] = '"& dh1 & "'")
        For c As Integer = 0 To 2
            'rt.Cells(4,c).Text = tb.Cols(c).Name
            rt.Cols(c).Width = "auto"
            rt.Style.TextColor = tb.ForeColor
            'tb.Cols(c).PrintWidth
            Dim y As Integer = Round2((Rows.Count)/3,0)
            For r As Integer = 0 To y -1
                If rows(r)("品名") Like "3E棕*" Then
                    rt.Cells(r + 4, c).Style.TextColor = tb.DataTable.Styles("3E棕").ForeColor
                ElseIf rows(r)("品名") Like "*棉"  Then
                    rt.Cells(r + 4, c).Style.TextColor = tb.DataTable.Styles("棉").ForeColor
                End If

                rt.Cells(r + 4, c).Text = rows(r)(tb.Cols(c).Name)
            Next
            For p As Integer = y To y*2-1
                If rows(p)("品名") Like "3E棕*" Then
                    rt.Cells(p-y+4, c+3).Style.TextColor = tb.DataTable.Styles("3E棕").ForeColor
                ElseIf Rows(p)("品名") Like "*棉"  Then
                    rt.Cells(p-y+4, c+3).Style.TextColor = tb.DataTable.Styles("棉").ForeColor
                End If
                rt.Cells(p-y+4, c+3).Text = rows(p)(tb.Cols(c).Name)
            Next
            For o As Integer = y*2 To Rows.Count-1
                If rows(o)("品名") Like "3E棕*" Then
                    rt.Cells(o-y*2+4,c+6).Style.TextColor = tb.DataTable.Styles("3E棕").ForeColor
                ElseIf Rows(o)("品名") Like "*棉"  Then
                    rt.Cells(o-y*2+4,c+6).Style.TextColor = tb.DataTable.Styles("棉").ForeColor
                End If
                rt.cells(o-y*2+4,c+6).text = Rows(o)(tb.Cols(c).name)
            Next
        Next
       
        rt.Cols(1).Width = 30
        rt.Cols(4).Width = 30
        rt.Cols(7).Width = 30
       
        rt.Cols(2).Width = 10
        rt.Cols(5).Width = 10
        rt.Cols(8).Width = 10
        rt.Cols(0).Width = 20
        rt.Cols(3).Width = 20
        rt.Cols(6).Width = 20
        rt.Style.TextAlignHorz = prt.AlignHorzEnum.center
        Doc.body.Children.Add(rt)
    Next
Next


doc.Preview()


 回到顶部