标出感兴趣的数据

用红色加粗字体标出金额超出一万的订单:

Dim doc As New PrintDoc '定义一个新报表
Dim
rt As New prt.RenderTable '定义一个新表格
Dim
tb as Table = Tables("订单")
rt.Width =
"Auto" '表格宽度为自动,也就是等于各列设置宽度之和
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font
For
c As Integer = 0 To tb.Cols.Count -1 '逐列设置和填入内容
    rt.Cells(
0,c).Text = tb.Cols(c).Name '列名作为标题
    rt.Cells(
0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
    rt.Cols(c).Width = tb.Cols(c).PrintWidth
'列宽等于实际列宽
   
If tb.Cols(c).IsNumeric Orelse tb.Cols(c).IsDate Then '如果是数值或日期列
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right
'数据水平靠右
   
End If
    For
r As integer = 0 To tb.Rows.Count -1 '开始填入该列内容
        rt.Cells(r +
1, c).Text = tb(r,c)
        If
tb.Cols(c).Name = "金额" Then
            If
tb.Rows(r)("金额") > 10000 Then
                rt.Cells(r +
1, c).Style.TextColor = Color.Red
                rt.Cells(r +
1, c).Style.FontBold =
True
            End If
        End
If
    Next
Next

rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
'灰色网格线
rt.CellStyle.Spacing.All =
0.5 '单元格内距设为0.5毫米
rt.Rows(
0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rt.RowGroups(
0,1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头
doc.Body.Children.Add(rt)
'将表格加入到报表

doc.Preview()


本页地址:http://www.foxtable.com/webhelp/topics/1236.htm