以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  报表0.00%的问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=77079)

--  作者:douglas738888
--  发布时间:2015/11/10 17:21:00
--  报表0.00%的问题
老师帮忙看看,多层表头中的环比不能转换为0.00%,但是0.00的显示正常

Dim doc As New PrintDoc \'定义一个新报表
Dim rt As New prt.RenderTable() \'定义一个新表格
Dim n As New prt.RenderText \'定义一个文本对象
Dim n1 As New prt.RenderText \'定义一个文本对象
Dim n3 As New prt.RenderText \'定义一个文本对象
Dim tb As Table = Tables("收支利润分析_Table1")
Dim hd As Integer = tb.HeaderRows \'获得表头的层数
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 \'指定垂直位置

n3.Style.Font = New Font("黑体", 8 , FontStyle.Bold) \'设置文本对象的字体
n3.Style.TextAlignHorz = prt.AlignHorzEnum.Left \'文本内容水平居中
n3.X = 5 + 20 \'指定水平位置
n3.y = 18 + 20 \'指定垂直位置
n3.Text = e.Form.Controls("Label5").Text

doc.Body.Children.Add(n3) \'将文本对象加入到报表
doc.Body.Children.Add(n1) 
doc.PageSetting.Landscape = True \'横向打印
rt.Width = "245" \'表格宽度为自动,也就是等于各列设置宽度之和
tb.CreateReportHeader(rt,False) \'生成表头,包括所有列
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 \'列宽等于实际列宽
    rt.Style.Spacing.Top = 10 \'表格和前面对象的垂直间隔为10毫米
    rt.Style.Spacing.Bottom = 10 \'表和和前对象的垂直间隔为10毫米
    If tb.Cols(c).IsNumeric OrElse tb.Cols(c).IsDate Then \'如果是数值或日期列
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平居中
    End If
    If tb.Cols(c).IsString OrElse tb.Cols(c).IsString Then \'如果是非数值列
        rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'非数值列水平居中
    End If

If tb.Cols(c).IsNumeric Then
    Select tb.Cols(c).Name
        Case "营业收入_订单金额","营业收入_预付定金","营业收入_增单收入","营业收入_订单欠款","营业收入_订单收入","营业支出_支出金额","营业利润_利润"
            For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
                rt.Cells(r + hd, c).Text = Format(tb(r,c), "0.00")
                rt.Rows(0).Height = 7 \'设置行高  
            Next 
       Case "营业收入_环比","营业支出_环比"
                For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容
                    rt.Cells(r + hd, 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 + hd, 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 + hd, c).Text = tb(r,c)
        rt.Rows(0).Height = 7 \'设置行高
        Next
End If
    Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Black) \'灰色网格线
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/11/10 17:24:00
--  

Select tb.Cols(c).Name

 

改成

 

Select tb.Cols(c).Caption


--  作者:douglas738888
--  发布时间:2015/11/10 17:28:00
--  
谢谢。大红袍老师!!!