以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  专业报表逻辑列问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=76423)

--  作者:douglas738888
--  发布时间:2015/10/28 17:49:00
--  专业报表逻辑列问题
请老师帮忙看看,下面代码,把小数位数代码加入后,逻辑列不会显示勾或叉,去掉后可正常显示逻辑列勾和叉
Dim doc As New PrintDoc \'定义一个新报表
Dim rt As New prt.RenderTable() \'定义一个新表格(收入)
Dim rt1 As New prt.RenderTable() \'定义一个新表格(支出)
Dim n As New prt.RenderText \'定义一个文本对象(标题)
Dim n1 As New prt.RenderText \'定义一个文本对象(报表当日时间)
Dim tb As Table = Tables("收支_Table1")
Dim tb1 As Table = Tables("收支_Table2")
Dim ColNames As New List(Of String)
For Each cl As Col In tb.Cols \'排除隐藏列
    If cl.Visible Then
        ColNames.Add(cl.Name)
    End If
Next

tb.Filter = "记账日期 = #" & Date.Today & "#"

n.Text = "日营业收支明细报表" \'设置文本对象的内容
n.Style.Font = New Font("黑体", 20 , FontStyle.Bold) \'设置文本对象的字体
n.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'文本内容水平居中
doc.Body.Children.Add(n) 

n1.Text = "日期:"& Date.Now  
n1.Style.Font = New Font("黑体", 8 , FontStyle.Bold) \'设置文本对象的字体
n1.Style.TextAlignHorz = prt.AlignHorzEnum.Right \'文本内容水平居中
n1.X = 0 + 20 \'指定水平位置
n1.y = 18 + 20 \'指定垂直位置

doc.Body.Children.Add(n1) \'将文本对象加入到报表
doc.PageSetting.Landscape = True \'横向打印

rt.Width = 243 \'表格宽度为自动,也就是等于各列设置宽度之和(营业收入)
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font
For c As Integer = 0 To ColNames.Count - 1 \'逐列设置和填入内容
    rt.Cells(0,c).Text = ColNames(c) \'列名作为标题
    rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中
    rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth \'列宽等于实际列宽
    If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then \'如果是数值或日期列
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右
    End If
    For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
        If tb.Cols(ColNames(c)).IsBoolean Then
            If tb.Rows(r)(ColNames(c))=True
                rt.Cells(r + 1, c).Text = "√"
            Else rt.Cells(r + 1, c).Text = "X"
            End If
        Else            
            rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
        End If
    Next

If tb.Cols(ColNames(c)).IsBoolean Then \'营业收入
    Select tb.Cols(ColNames(c)).Name
        Case "订单金额","预付定金","欠款合计"
            For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
                rt.Cells(r + 1, c).Text = Format(tb(r,c),"0.00")                        
                rt.Rows(0).Height = 7 \'设置行高
            Next
        Case Else
            For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
                rt.Cells(r + 1, c).Text = Format(tb(r,c), "0")
                rt.Rows(0).Height = 7 \'设置行高
            Next
    End Select
Else
    For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
        rt.Cells(r + 1, c).Text = tb(r,c)
        rt.Rows(0).Height = 7 \'设置行高
    Next
    For i As Integer = 1 To 4
    rt.Rows(i).Height = 5.5
Next
End If


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 \'利用行组,将第一行设为表头
rt.Style.Font = New Font("宋体", 10 , FontStyle.Bold) \'设置文本对象的字体
doc.Body.Children.Add(rt) \'将表格加入到报表
doc.Preview()

--  作者:大红袍
--  发布时间:2015/10/28 18:02:00
--  

Dim doc As New PrintDoc \'定义一个新报表
Dim rt As New prt.RenderTable() \'定义一个新表格(收入)
Dim rt1 As New prt.RenderTable() \'定义一个新表格(支出)
Dim n As New prt.RenderText \'定义一个文本对象(标题)
Dim n1 As New prt.RenderText \'定义一个文本对象(报表当日时间)
Dim tb As Table = Tables("收支_Table1")
Dim tb1 As Table = Tables("收支_Table2")
Dim ColNames As New List(Of String)
For Each cl As Col In tb.Cols \'排除隐藏列
    If cl.Visible Then
        ColNames.Add(cl.Name)
    End If
Next


tb.Filter = "记账日期 = #" & Date.Today & "#"


n.Text = "日营业收支明细报表" \'设置文本对象的内容
n.Style.Font = New Font("黑体", 20 , FontStyle.Bold) \'设置文本对象的字体
n.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'文本内容水平居中
doc.Body.Children.Add(n)


n1.Text = "日期:"& Date.Now
n1.Style.Font = New Font("黑体", 8 , FontStyle.Bold) \'设置文本对象的字体
n1.Style.TextAlignHorz = prt.AlignHorzEnum.Right \'文本内容水平居中
n1.X = 0 + 20 \'指定水平位置
n1.y = 18 + 20 \'指定垂直位置


doc.Body.Children.Add(n1) \'将文本对象加入到报表
doc.PageSetting.Landscape = True \'横向打印


rt.Width = 243 \'表格宽度为自动,也就是等于各列设置宽度之和(营业收入)
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font
For c As Integer = 0 To ColNames.Count - 1 \'逐列设置和填入内容
    rt.Cells(0,c).Text = ColNames(c) \'列名作为标题
    rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中
    rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth \'列宽等于实际列宽
    If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then \'如果是数值或日期列
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右
    End If
   
    If tb.Cols(ColNames(c)).IsBoolean Then
        For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
            If tb.Rows(r)(ColNames(c))=True
                rt.Cells(r + 1, c).Text = "√"
            Else
                rt.Cells(r + 1, c).Text = "X"
            End If
        Next
    Else
        If tb.Cols(ColNames(c)).IsNumeric Then \'营业收入
            Select tb.Cols(ColNames(c)).Name
                Case "订单金额","预付定金","欠款合计"
                    For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
                        rt.Cells(r + 1, c).Text = Format(tb(r,c),"0.00")
                        rt.Rows(0).Height = 7 \'设置行高
                    Next
                Case Else
                    For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
                        rt.Cells(r + 1, c).Text = Format(tb(r,c), "0")
                        rt.Rows(0).Height = 7 \'设置行高
                    Next
            End Select
        Else
            For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
                rt.Cells(r + 1, c).Text = tb(r,c)
                rt.Rows(0).Height = 7 \'设置行高
            Next
            For i As Integer = 1 To 4
                rt.Rows(i).Height = 5.5
            Next
        End If
    End If
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 \'利用行组,将第一行设为表头
rt.Style.Font = New Font("宋体", 10 , FontStyle.Bold) \'设置文本对象的字体
doc.Body.Children.Add(rt) \'将表格加入到报表
doc.Preview()


--  作者:douglas738888
--  发布时间:2015/10/28 18:16:00
--  
明白了,谢谢老师!!