Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共4 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:只打印有值的列

1楼
deliangzhaoe 发表于:2024/5/12 18:28:00
想实现只打印列的值不全部是空的列,只要本列有一个数值,本列即打印,本列无任何数值全部为空则本列不打印。

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20240512181542.png
图片点击可在新窗口打开查看
怎么设置?谢谢老师!

现在设置的代码是这样的:
'页面设置
Dim doc As New PrintDoc '定义一个报表
Doc.PageSetting.LeftMargin = 15
Doc.PageSetting.BottomMargin = 15
Doc.PageSetting.TopMargin = 15
Doc.PageSetting.rightMargin = 15
Dim rm As prt.RenderEmpty '定一个空对象
doc.Pagesetting.LandScape = True
'设置页脚
Dim yj As New prt.RenderText '定义一个文本对象
yj = New prt.RenderText '设置文本对象的内容
yj.Text = "第[PageNo]页  共[PageCount]页" '设置文本内容
yj.Style.TextAlignHorz = prt.AlignHorzEnum.center '页脚中间对齐
yj.Style.Font = New Font("宋体", 10) '字体大小为10磅
yj.Style.Padding.Bottom = -10 '底端内容缩进10毫米
Doc.PageFooter = yj '作为页脚使用
Dim tbl8 As Table = Tables("劳保发放标准") 

Dim rt8 As Prt.RenderTable
Dim rx8 As prt.RenderText
Dim Rows8 As List(Of DataRow)
'设置二级标题
rx8 = New prt.RenderText
rx8.Style.Font = New Font("宋体", 16)
rx8.Style.Spacing.Bottom = 5
Dim dr As String = Forms("mainform").controls("劳保发放企业名称").value
rx8.text = dr & vbcrlf & "劳动防护用品发放标准" '表标题显示企业名称
rx8.Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题水平居中
doc.Body.Children.Add(rx8)
'设置表格样式
rt8 = New prt.RenderTable
rt8.Style.TextAlignVert = prt.AlignVertEnum.Center
rt8.Style.GridLines.All = New prt.LineDef(0.3,Color.blue)
rt8.Style.Spacing.Bottom = 5
rt8.CellStyle.Spacing.All = 1
rt8.Style.Font = New Font("宋体", 11)
'设置表格细节
Rows8 = tbl8.DataTable.Select("企业名称 Like '*" & Forms("mainform").controls("劳保发放企业名称").value & "*'“,"部门") '指定符合条件的行和排序方式
Dim nms8() As String = {"企业名称","部门","岗位","身份证号","所在部门","接害种类","查体类别","查体项目","查体日期","查体结论","查体机构"} '指定要显示的列即要打印的列
Dim caps() As String = {"序号","部门","岗位","身份证号","所在部门","接害种类","查体类别","查体项目","查体日期","查体结论","查体机构"} '自定义列名
    For c As Integer = 0 To nms8.length - 1
        Dim ary() As String = caps(c).split("|")
        For i As Integer = 0 To ary.length-1
            rt8.cells(i, c).text = ary(i)
        Next    '打印的列标题自定义
    'rt8.Cells(0,c).Text = tbl8.Cols(nms8(c)).Name  '使用原列名
    rt8.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
    'rt8.Cols(c).Width = tbl8.Cols(c).PrintWidth '根据原表格确定列宽
    rt8.Cols(0).Width = 15 '设置各列宽度
    rt8.Cols(1).Width = 15
    rt8.Cols(2).Width = 20
    rt8.Cols(3).Width = 45
    rt8.Cols(4).Width = 25
    rt8.Cols(5).Width = 30
    rt8.Cols(6).Width = 20
    rt8.Cols(7).Width = 40
    rt8.Cols(8).Width = 25
rt8.Cols(9).Width = 25
rt8.Cols(10).Width = 35
For r As Integer = 0 To Rows8.Count -1
            If c=0 Then
                rt8.Cells(r + 1, c).Text = r + 1 '增加了序号列,并自动填充
            Else
                rt8.Cells(r + 1, c).Text = rows8(r)(tbl8.Cols(nms8(c)).Name)
            End If
        Next
    Next
rt8.RowGroups(0,1).Header = prt.TableHeaderEnum.All
doc.Body.Children.Add(rt8)
Doc.Preview() '预览报表
[此贴子已经被作者于2024/5/12 18:29:13编辑过]
2楼
lihe60 发表于:2024/5/12 19:31:00
按条件加载或生成报表
3楼
deliangzhaoe 发表于:2024/5/12 20:23:00
条件不会写

4楼
有点蓝 发表于:2024/5/12 20:33:00
获取有数据的列名,比如

dim lst as new list(of string)
for each c as col in tbl8.cols
if tbl8.compute("count(" & c.name & ")",c.name & " is not null") > 0 then
lst.add(c.name)
end if
next
[此贴子已经被作者于2024/5/12 20:32:49编辑过]
共4 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03394 s, 2 queries.