以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  打印预览时不出现符合条件的行  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=172390)

--  作者:deliangzhaoe
--  发布时间:2021/10/10 20:23:00
--  打印预览时不出现符合条件的行
打印预览按钮设置了如下代码:
\'页面设置
Dim doc As New PrintDoc \'定义一个报表
Doc.PageSetting.LeftMargin = 10
Doc.PageSetting.BottomMargin = 10
Doc.PageSetting.TopMargin = 10
Doc.PageSetting.rightMargin = 10
doc.Pagesetting.LandScape = False
\'设置页脚
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 = -5 \'底端内容缩进10毫米
Doc.PageFooter = yj \'作为页脚使用
Dim tbl8 As Table = Tables("目标考核奖惩_table1")
\'标题
Dim rx8 As prt.RenderText
Dim Rows8 As List(Of DataRow)
rx8 = New prt.RenderText
rx8.Style.Font = New Font("宋体", 14)
rx8.Style.Spacing.Bottom = 5
Dim dr As String = e.Form.controls("目标考核奖惩企名").value
rx8.text = dr & vbcrlf & "安全目标考核奖惩情况"
rx8.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题水平居中
doc.Body.Children.Add(rx8)
\'设置表样式
Dim rt8 As Prt.RenderTable
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 = 0
rt8.CellStyle.Spacing.All = 1
rt8.Style.Font = New Font("宋体", 11)
\'设置表格细节
If e.Form.controls("目标考核奖惩考核日期起").value IsNot Nothing AndAlso e.Form.controls("目标考核奖惩考核日期止").value IsNot Nothing Then
    Rows8 = tbl8.DataTable.Select("企业名称 Like \'*" & e.Form.controls("目标考核奖惩企名").value & "*\' And 年度 Like \'*" & e.Form.controls("目标考核奖惩年度").value & "*\' and 考核日期 >= #" & e.Form.controls("目标考核奖惩考核日期起").value & "# and 考核日期 <= #" & e.Form.controls("目标考核奖惩考核日期止").value & "# And 被考核部门 Like \'*" & e.Form.controls("目标考核奖惩部门").value & "*\' And 被考核岗位 Like \'*" & e.Form.controls("目标考核奖惩岗位").value & "*\' And 被考核人 Like \'*" & e.Form.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).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中
        \'rt8.Cols(c).Width = tbl8.Cols(c).PrintWidth \'根据原表格确定列宽
        rt8.Cols(0).Width = 12 \'设置各列宽度
        rt8.Cols(1).Width = 15
        rt8.Cols(2).Width = 30
        rt8.Cols(3).Width = 30
        rt8.Cols(4).Width = 20
        rt8.Cols(5).Width = 25
        rt8.Cols(6).Width = 20
        rt8.Cols(7).Width = 20
        
        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)
    \'设置最后表格样式
    Dim rt As Prt.RenderTable
    rt = New prt.RenderTable
    rt.Rows.Count = 1 \'设置总行数
    rt.Cols.Count = 6 \'设置总列数
    rt.Height = 10 \'设置表格的高度
    rt.Style.Font = New Font("宋体", 11)
    rt.Style.GridLines.All = New prt.LineDef(0.3,Color.blue)
    \'设置表格样式
    rt.CellStyle.Spacing.All = 1 \'单元格内容缩进1毫米
    rt.Style.GridLines.All = New prt.Linedef \'设置网格线
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题水平居中
    rt.Cells(0,0).Text= "编制"
    rt.Cells(0,2).Text= "审核"
    rt.Cells(0,4).Text= "批准"
    Doc.Body.ChildRen.Add(rt) \'将容器加入到报表中
End If
Doc.Preview() \'预览报表


表中有符合条件的行,但是预览时不出现符合条件的行

图片点击可在新窗口打开查看此主题相关图片如下:捕获.jpg
图片点击可在新窗口打开查看

老师帮忙看一下代码有什么问题,谢谢!


--  作者:有点蓝
--  发布时间:2021/10/10 20:27:00
--  
学会调试

Rows8 = tbl8.DataTable.Select("企业名称 Like \'*" & e.Form.controls("目标考核奖惩企名").value & "*\' And 年度 Like \'*" & e.Form.controls("目标考核奖惩年度").value & "*\' and 考核日期 >= #" & e.Form.controls("目标考核奖惩考核日期起").value & "# and 考核日期 <= #" & e.Form.controls("目标考核奖惩考核日期止").value & "# And 被考核部门 Like \'*" & e.Form.controls("目标考核奖惩部门").value & "*\' And 被考核岗位 Like \'*" & e.Form.controls("目标考核奖惩岗位").value & "*\' And 被考核人 Like \'*" & e.Form.controls("目标考核奖惩被考核人").value & "*\'","年度,考核日期") \'指定符合条件的行和排序方式
msgbox(Rows8.count) \'查询结果有几行?

另外把like里的*改为%

--  作者:deliangzhaoe
--  发布时间:2021/10/10 20:27:00
--  
相似的代码,在另一个窗口中 ,预览时是这样的:

图片点击可在新窗口打开查看此主题相关图片如下:捕获2.jpg
图片点击可在新窗口打开查看

代码如下:
\'页面设置
Dim doc As New PrintDoc \'定义一个报表
Doc.PageSetting.LeftMargin = 10
Doc.PageSetting.BottomMargin = 10
Doc.PageSetting.TopMargin = 10
Doc.PageSetting.rightMargin = 10
doc.Pagesetting.LandScape = False
\'设置页脚
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 = -5 \'底端内容缩进10毫米
Doc.PageFooter = yj \'作为页脚使用
Dim tbl8 As Table = Tables("责任制考核奖惩_table1")
\'标题
Dim rx8 As prt.RenderText
Dim Rows8 As List(Of DataRow)
rx8 = New prt.RenderText
rx8.Style.Font = New Font("宋体", 14)
rx8.Style.Spacing.Bottom = 5
Dim dr As String = e.Form.controls("combobox7").value
rx8.text = dr & vbcrlf & "安全生产责任制考核奖惩情况"
rx8.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题水平居中
doc.Body.Children.Add(rx8)
\'设置表样式
Dim rt8 As Prt.RenderTable
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 = 0
rt8.CellStyle.Spacing.All = 1
rt8.Style.Font = New Font("宋体", 11)
\'设置表格细节
If e.Form.controls("datetimepicker2").value IsNot Nothing AndAlso e.Form.controls("datetimepicker3").value IsNot Nothing Then
    Rows8 = tbl8.DataTable.Select("[企业名称] Like \'*" & e.Form.controls("combobox7").value & "*\' And 年度 Like \'*" & e.Form.controls("combobox6").value & "*\' and 考核日期 >= #" & e.Form.controls("datetimepicker2").value & "# and 考核日期 <= #" & e.Form.controls("datetimepicker3").value & "# And 被考核部门 Like \'*" & e.Form.controls("combobox1").value & "*\' And 被考核岗位 Like \'*" & e.Form.controls("combobox2").value & "*\' And 被考核人 Like \'*" & e.Form.controls("combobox8").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).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中
        \'rt8.Cols(c).Width = tbl8.Cols(c).PrintWidth \'根据原表格确定列宽
        rt8.Cols(0).Width = 12 \'设置各列宽度
        rt8.Cols(1).Width = 15
        rt8.Cols(2).Width = 30
        rt8.Cols(3).Width = 30
        rt8.Cols(4).Width = 20
        rt8.Cols(5).Width = 25
        rt8.Cols(6).Width = 20
        rt8.Cols(7).Width = 20
        
        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)
    \'设置最后表格样式
    Dim rt As Prt.RenderTable
    rt = New prt.RenderTable
    rt.Rows.Count = 1 \'设置总行数
    rt.Cols.Count = 6 \'设置总列数
    rt.Height = 10 \'设置表格的高度
    rt.Style.Font = New Font("宋体", 11)
    rt.Style.GridLines.All = New prt.LineDef(0.3,Color.blue)
    \'设置表格样式
    rt.CellStyle.Spacing.All = 1 \'单元格内容缩进1毫米
    rt.Style.GridLines.All = New prt.Linedef \'设置网格线
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中
    rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题水平居中
    rt.Cells(0,0).Text= "编制"
    rt.Cells(0,2).Text= "审核"
    rt.Cells(0,4).Text= "批准"
    Doc.Body.ChildRen.Add(rt) \'将容器加入到报表中
End If
Doc.Preview() \'预览报表


--  作者:deliangzhaoe
--  发布时间:2021/10/10 20:47:00
--  
0行
--  作者:有点蓝
--  发布时间:2021/10/10 21:01:00
--  
把like里的*改为%

Rows8 = tbl8.DataTable.Select("[企业名称] Like \'%" & e.Form.controls("comb

如果还不行,说明没有同时符合这些条件的数据