以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]专业报表将份额和占比转换百分比?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=9174)

--  作者:易服
--  发布时间:2011/3/7 11:11:00
--  [求助]专业报表将份额和占比转换百分比?


此主题相关图片如下:2011-3-7 11-00-27.png
按此在新窗口浏览图片
 g.HorizontalProportion = True

 g.VerticalProportion = True


--  作者:狐狸爸爸
--  发布时间:2011/3/7 11:27:00
--  

这样:

 

rx.Text = Format(r("列名"),"#0.00%")


--  作者:易服
--  发布时间:2011/3/7 12:00:00
--  

 这是个动态报表,不知怎么加  rx.Text = Format(r("列名"),"#0.00%")

 


图片点击可在新窗口打开查看此主题相关图片如下:2011-3-7 11-48-44.png
图片点击可在新窗口打开查看
 

 帖子内容长度不能大于16240,您已经输入了35319个字

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:报表代码.txt

[此贴子已经被作者于2011-3-7 12:00:44编辑过]

--  作者:狐狸爸爸
--  发布时间:2011/3/7 12:35:00
--  
For Each Col AS DataCol In Dt.DataCols
    rt.Cells(0,Count).Text = Col.Caption
    For r As Integer = 0 To dt.DataRows.Count - 1
        If col.Name = "要百分比显示的列的名称" Then
            rt.Cells(r +1,Count).Text = Format(dt.DataRows(r)(Col.Name ),"#0.00%")
        Else
           rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name )
        End If
    Next
    Count = Count + 1
Next

--  作者:易服
--  发布时间:2011/3/7 17:49:00
--  
以下是引用狐狸爸爸在2011-3-7 12:35:00的发言:
For Each Col AS DataCol In Dt.DataCols
    rt.Cells(0,Count).Text = Col.Caption
    For r As Integer = 0 To dt.DataRows.Count - 1
        If col.Name = "要百分比显示的列的名称" Then
            rt.Cells(r +1,Count).Text = Format(dt.DataRows(r)(Col.Name ),"#0.00%")
        Else
           rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name )
        End If
    Next
    Count = Count + 1
Next

试了多次不生效,不知是不是这样

用      If col.Name = "要百分比显示的列的名称" Then
            rt.Cells(r +1,Count).Text = Format(dt.DataRows(r)(Col.Name ),"#0.00%")
        Else
           rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name )
        End If
代换原 rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name )


--  作者:狐狸爸爸
--  发布时间:2011/3/7 17:56:00
--  

是的


--  作者:易服
--  发布时间:2011/3/8 15:47:00
--  

不行的,  If col.Name = "林种" Then 或"林龄""登记权利""林分起源""面积"

都不会百分比显示。还请狐爸费心!


--  作者:狐狸爸爸
--  发布时间:2011/3/8 15:49:00
--  
Select Col.Name
      case "百分比列名1"," 百分比列名2, "百分比列名3" ......
            rt.Cells(r +1,Count).Text = Format(dt.DataRows(r)(Col.Name ),"#0.00%")
      case else
           rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name )
End Select

--  作者:易服
--  发布时间:2011/3/8 16:10:00
--  

还是不行

For Each Col AS DataCol In Dt.DataCols
      rt.Cells(0,Count).Text = Col.Caption
      For r As Integer = 0 To dt.DataRows.Count - 1
            Select Col.Name
                   Case "林龄","登记权利" ,"林分起源" ,"林种"
                        rt.Cells(r +1,Count).Text = Format(dt.DataRows(r)(Col.Name ),"#0.00%")
                   Case Else
                        rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name )
             End Select
       Next
           Count = Count + 1
 Next


--  作者:狐狸爸爸
--  发布时间:2011/3/8 16:17:00
--  

这么设置后,显示的成什么样了?

你是不是列名错了,注意列名和标题不一定相同的。