以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]专业报表中如何不显示无内容的列  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=115769)

--  作者:huangfanzi
--  发布时间:2018/3/14 12:01:00
--  [求助]专业报表中如何不显示无内容的列
例如以下代码:
Dim doc As New PrintDoc
Dim rt As New Prt.RenderTable
Dim rx As prt.RenderText
Dim cnt As Integer
Dim tbl As Table = Tables("订单")
Dim drs As List(Of DataRow)
Dim pds As List(Of String) = tbl.DataTable.GetValues("产品",tbl.Filter)
rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
rt.CellStyle.Spacing.All = 1
rt.Style.Font = tbl.Font
For c As Integer = 0 To tbl.Cols.Count - 1 \'生成列标题
    rt.Cells(0,c).Text = tbl.Cols(c).Name
    rt.Cols(c).Width = tbl.Cols(c).PrintWidth
Next
...

如果订单表中的某一列没有任何数据,那么在生成列标题时希望不要生成这个列,请问老师应该如何写代码,谢谢!

--  作者:有点甜
--  发布时间:2018/3/14 12:15:00
--  
Dim doc As New PrintDoc
Dim rt As New Prt.RenderTable
Dim rx As prt.RenderText
Dim cnt As Integer
Dim tbl As Table = Tables("订单")
Dim drs As List(Of DataRow)
Dim pds As List(Of String) = tbl.DataTable.GetValues("产品",tbl.Filter)
rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
rt.CellStyle.Spacing.All = 1
rt.Style.Font = tbl.Font
Dim i As Integer = 0
For c As Integer = 0 To tbl.Cols.Count - 1 \'生成列标题
    Dim idx = tbl.FindRow(tbl.cols(c).name & " Is not null")
    If idx >= 0 Then
        rt.Cells(0,i).Text = tbl.Cols(c).Name
        rt.Cols(i).Width = tbl.Cols(c).PrintWidth
        i += 1
    End If
Next