Foxtable(狐表)用户栏目专家坐堂 → 【专业报表】窗体打开第一行可以预览报表,结果选择第二行就出错了?


  共有1776人关注过本帖树形打印复制链接

主题:【专业报表】窗体打开第一行可以预览报表,结果选择第二行就出错了?

帅哥哟,离线,有人找我吗?
李孝春
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
【专业报表】窗体打开第一行可以预览报表,结果选择第二行就出错了?  发帖心情 Post By:2017/11/10 18:02:00 [只看该作者]


【专业报表】窗体打开第一行可以预览报表,结果选择第二行就出错了?

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

图片点击可在新窗口打开查看此主题相关图片如下:2.jpg
图片点击可在新窗口打开查看
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:瓮安县院卷宗管理系统1110 - 副本.part1.rar
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:瓮安县院卷宗管理系统1110 - 副本.part2.rar

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:专业报表.txt
代码如下:
Dim doc As New PrintDoc '定义一个报表
Dim Rows As List(Of DataRow)
Dim CurRow As Row = Tables("卷宗入库").Current
Dim ndr As DataRow = DataTables("涉案款物").find("案件编号 = '" & currow("卷宗编号") & "'")
Dim drs1 = DataTables("入库明细").Select("卷宗编号 = '" & currow("卷宗编号") & "'")
Dim drs2 = DataTables("款物明细").Select("案件编号 = '" & currow("卷宗编号") & "'")
Dim drs3 = DataTables("扫码录入").Select("卷宗编号 = '" & currow("卷宗编号") & "'")
Dim drs4 = DataTables("款物录入").Select("案件编号 = '" & currow("卷宗编号") & "'")
Dim bg As New prt.RenderTable() '定义一个表格对象

bg.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
bg.CellStyle.Spacing.All = 1 '内容距离网格线1毫米
bg.Width = 160 '表宽为150毫米
bg.Height = 50 '表高为150毫米
bg.Rows.Count = 6 '设置行数
bg.Cols.Count = 6 '设置列数
bg.Cells(0,0).text = "贵州省瓮安县人民检察院"
bg.Cells(0,0).SpanCols = 6 '合并第一行全部单元格,用于显示主标题
bg.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '主标题居中
bg.Cells(0,0).Style.Font = New Font("宋体", 16, FontStyle.Bold) '设置主标题字体
bg.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第一行的网格线
'设置副标题
bg.Cells(1,0).text = "涉案卷宗及财物二维码管理系统" '通过左边空格数量来调整副标题位置
bg.Cells(1,0).SpanCols = 6 '合并地二行全部单元格,用于显示副标题
bg.Cells(1,0).Style.Font = New Font("宋体", 16, FontStyle.Bold) '设置主标题字体
bg.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '副标题内容居中
bg.Rows(1).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第二行的网格线
bg.Rows(1).Style.Borders.Bottom = New prt.Linedef  '恢复第二行底端的网格线
bg.Rows(1).Height = 8 '设置第二行的高度,拉开和表格主体的距离.
'设置列标题

bg.Cells(2,0).text = "基本信息" '通过左边空格数量来调整副标题位置
bg.Cells(2,0).SpanCols = 3 '合并地二行全部单元格,用于显示副标题
bg.Cells(2,0).Style.Font = New Font("宋体", 10, FontStyle.Bold) '设置主标题字体
bg.Cells(2,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '副标题内容居中
bg.Cells(2,3).text = "卷宗编号"
bg.Cells(2,3).Style.TextAlignHorz = prt.AlignHorzEnum.right '副标题内容居中
bg.Cells(2,4).text = currow("卷宗编号")  '通过左边空格数量来调整副标题位置
bg.Cells(2,4).SpanCols = 2 '合并地二行全部单元格,用于显示副标题
bg.Cells(2,4).Style.Font = New Font("宋体", 10, FontStyle.Bold) '设置主标题字体
bg.Cells(2,4).Style.TextAlignHorz = prt.AlignHorzEnum.Center '副标题内容居中

bg.Rows(2).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第二行的网格线
bg.cells(2,0).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第二行的网格线
bg.cells(2,3).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第二行的网格线
bg.cells(2,3).Style.Borders.Bottom = New prt.Linedef  '恢复第二行底端的网格线
bg.cells(2,0).Style.Borders.Bottom = New prt.Linedef  '恢复第二行底端的网格线
bg.Rows(2).Style.Borders.Bottom = New prt.Linedef  '恢复第二行底端的网格线
bg.Rows(2).Height = 8 '设置第二行的高度,拉开和表格主体的距离.
'设置列标题
bg.Cols(0).Width = 20
bg.Cols(1).Width = 45
bg.Cols(2).Width = 20
bg.Cols(3).Width = 45
bg.Cols(4).Width = 20
bg.Cols(5).Width = 20
bg.Rows.Count = 4
bg.Rows(0).Height = 15
bg.Rows(1).Height = 15
bg.Rows(2).Height = 10
bg.Rows(3).Height = 10
bg.Rows(4).Height = 10
bg.Rows(5).Height = 10
bg.Rows(6).Height = 10
bg.Style.TextAlignHorz = prt.AlignHorzEnum.Center '所有文本内容居中'
bg.Cells(3,0).Text = "所属地州"
bg.Cells(3,1).Text = CurRow("所属地州")
bg.Cells(3,2).Text = "卷宗名称"
bg.Cells(3,3).Text = CurRow("卷宗名称")
bg.Cells(3,4).Text = "涉案款物"
bg.Cells(3,5).Text = CurRow("涉案款物")

bg.Cells(4,0).Text = "所属单位"
bg.Cells(4,1).Text = CurRow("所属单位")
bg.Cells(4,2).Text = "卷宗册数"
bg.Cells(4,3).Text = CurRow("卷宗册数")
bg.Cells(4,4).Text = "款物数量"
bg.Cells(4,5).Text = ndr("款物数量")
bg.Cells(5,0).Text = "承办部门"
bg.Cells(5,1).Text = CurRow("承办部门")
bg.Cells(5,2).Text = "承办人员"
bg.Cells(5,3).Text = CurRow("承办人")
bg.Cells(5,4).Text = "使用人员"
bg.Cells(5,5).Text = CurRow("使用人")
bg.Cells(6,0).Text = "录入时间"
bg.Cells(6,1).Text = CurRow("录入时间")
bg.Cells(6,2).Text = "联系电话"
bg.Cells(6,3).Text = CurRow("联系电话")
bg.Cells(6,4).Text = "办理状态"
bg.Cells(6,5).Text = CurRow("办理状态")
 

Dim bg1 As New prt.RenderTable() '定义一个表格对象

bg1.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
bg1.CellStyle.Spacing.All = 1 '内容距离网格线1毫米
bg1.Width = 160 '表宽为150毫米
'bg1.Height = 50 '表高为150毫米
bg1.Rows.Count = 3 '设置行数
bg1.Cols.Count = 4 '设置列数
bg1.Cells(0,0).text = "卷宗分册信息"
bg1.Cells(0,0).SpanCols = 4 '合并第一行全部单元格,用于显示主标题
bg1.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
bg1.Cells(0,0).Style.Font = New Font("宋体", 10, FontStyle.Bold) '设置主标题字体
bg1.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第一行的网格线
bg1.Rows(0).Style.Borders.Bottom = New prt.Linedef  '恢复第一行底端的网格线
bg1.Rows(0).Height = 8 '设置第一行的高度,拉开和表格主体的距离.
bg1.Rows(1).Height = 10
bg1.Rows(2).Height = 10
bg1.Cols(0).Width = 50
bg1.Cols(1).Width = 20
bg1.Cols(2).Width = 20
bg1.Cols(3).Width = 20

bg1.Style.TextAlignHorz = prt.AlignHorzEnum.Center '所有文本内容水平居中'
bg1.Style.TextAlignVert = prt.AlignVertEnum.Center '所有文本内容垂直居中'
bg1.Cells(1,0).Text = "卷宗名称"
bg1.Cells(1,1).Text = "卷宗册数"
bg1.Cells(1,2).Text = "分册编号"
bg1.Cells(1,3).Text = "二维码"
For i As Integer = 0 To drs1.count-1
    Dim ndr1 = drs1(i)
    Dim rm As New prt.RenderImage()
    rm.Image = GetImage(ndr1("二维码")) '请改为实际的图标名称和路径
    rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center '图片水平居中
    rm.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center '图片垂直居中
    rm.Style.ImageAlign.StretchHorz = True '禁止水平方向扩展图片
    rm.Style.ImageAlign.StretchVert = True '禁止垂直方向扩展图片

    bg1.Cells(2+i,3).RenderObject = rm '将单元格内容设置为图片对象rm
    
    bg1.Rows(2+i).Height = 20
    
    
    bg1.Cells(2+i,0).Text = ndr1("卷宗名称")
    bg1.Cells(2+i,1).Text = ndr1("卷宗册数")
    bg1.Cells(2+i,2).Text = ndr1("分册编号")
    bg1.Cells(2+i,3).Image = GetImage(ndr1("二维码"))
    'doc.Body.Children.Add(rm) 
Next
bg1.Style.Spacing.Top = 1

Dim bg2 As New prt.RenderTable() '定义一个表格对象

bg2.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
bg2.CellStyle.Spacing.All = 1 '内容距离网格线1毫米
bg2.Width = 160 '表宽为150毫米
'bg2.Height = 50 '表高为150毫米
bg2.Rows.Count = 3 '设置行数
bg2.Cols.Count = 4 '设置列数
bg2.Cells(0,0).text = "款物序号信息"
bg2.Cells(0,0).SpanCols = 4 '合并第一行全部单元格,用于显示主标题
bg2.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
bg2.Cells(0,0).Style.Font = New Font("宋体", 10, FontStyle.Bold) '设置主标题字体
bg2.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第一行的网格线
bg2.Rows(0).Style.Borders.Bottom = New prt.Linedef  '恢复第一行底端的网格线
bg2.Rows(0).Height = 8 '设置第一行的高度,拉开和表格主体的距离.
bg2.Rows(1).Height = 10
bg2.Cols(0).Width = 50
bg2.Cols(1).Width = 20
bg2.Cols(2).Width = 20
bg2.Cols(3).Width = 20

bg2.Style.TextAlignHorz = prt.AlignHorzEnum.Center '所有文本内容水平居中'
bg2.Style.TextAlignVert = prt.AlignVertEnum.Center '所有文本内容垂直居中'
bg2.Cells(1,0).Text = "款物名称"
bg2.Cells(1,1).Text = "款物数量"
bg2.Cells(1,2).Text = "款物序号"
bg2.Cells(1,3).Text = "二维码"




For i As Integer = 0 To drs2.count-1
Dim ndr11 = drs2(i)
Dim rm1 As New prt.RenderImage()
    rm1.Image = GetImage(ndr11("二维码")) '请改为实际的图标名称和路径
    rm1.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center '图片水平居中
    rm1.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center '图片垂直居中
    rm1.Style.ImageAlign.StretchHorz = True '禁止水平方向扩展图片
    rm1.Style.ImageAlign.StretchVert = True '禁止垂直方向扩展图片

    bg2.Cells(2+i,3).RenderObject = rm1 '将单元格内容设置为图片对象rm



    
    bg2.Rows(2+i).Height = 20
    bg2.Cells(2+i,0).Text = ndr11("款物名称")
    bg2.Cells(2+i,1).Text = ndr11("款物数量")
    bg2.Cells(2+i,2).Text = ndr11("款物序号")
    bg2.Cells(2+i,3).Image = GetImage(ndr11("二维码"))
Next
bg2.Style.Spacing.Top = 1



Dim bg3 As New prt.RenderTable() '定义一个表格对象

bg3.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
bg3.CellStyle.Spacing.All = 1 '内容距离网格线1毫米

bg3.Width = 160 '表宽为150毫米
'bg3.Height = 50 '表高为150毫米
bg3.Rows.Count = 3 '设置行数
bg3.Cols.Count = 6 '设置列数

bg3.Cells(0,0).text = "卷宗使用信息"
bg3.Cells(0,0).SpanCols = 6 '合并第一行全部单元格,用于显示主标题
bg3.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
bg3.Cells(0,0).Style.Font = New Font("宋体", 10, FontStyle.Bold) '设置主标题字体
bg3.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第一行的网格线
bg3.Rows(0).Style.Borders.Bottom = New prt.Linedef  '恢复第一行底端的网格线
bg3.Rows(0).Height = 8 '设置第一行的高度,拉开和表格主体的距离.
bg3.Rows(1).Height = 10
bg3.Rows(2).Height = 10
bg3.Cols(0).Width = 40
bg3.Cols(1).Width = 12
bg3.Cols(2).Width = 12
bg3.Cols(3).Width = 10
bg3.Cols(4).Width = 30
bg3.Cols(5).Width = 12


bg3.Style.TextAlignHorz = prt.AlignHorzEnum.Center '所有文本内容水平居中'
bg3.Style.TextAlignVert = prt.AlignVertEnum.Center '所有文本内容垂直居中'

bg3.Cells(1,0).Text = "卷宗名称"
bg3.Cells(1,1).Text = "卷宗册数"
bg3.Cells(1,2).Text = "分册编号"
bg3.Cells(1,3).Text = "使用人"
bg3.Cells(1,4).Text = "登记时间"
bg3.Cells(1,5).Text = "登记状态"

For i As Integer = 0 To drs3.count- 1
    Dim ndr2=drs3(i)
    bg3.Rows(2+i).Height = 10
    bg3.Cells(2+i,0).Text = ndr2("卷宗名称")
    bg3.Cells(2+i,1).Text = ndr2("卷宗册数")
    bg3.Cells(2+i,2).Text = ndr2("分册编号")
    bg3.Cells(2+i,3).Text = ndr2("使用人")
    bg3.Cells(2+i,4).Text = ndr2("录入时间")
    bg3.Cells(2+i,5).Text = ndr2("登记状态")
Next
bg3.Style.Spacing.Top=1

Dim bg4 As New prt.RenderTable() '定义一个表格对象

bg4.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
bg4.CellStyle.Spacing.All = 1 '内容距离网格线1毫米

bg4.Width = 160 '表宽为150毫米
'bg4.Height = 50 '表高为150毫米
bg4.Rows.Count = 3 '设置行数
bg4.Cols.Count = 6 '设置列数

bg4.Cells(0,0).text = "款物使用信息"
bg4.Cells(0,0).SpanCols = 6 '合并第一行全部单元格,用于显示主标题
bg4.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.left '主标题居中
bg4.Cells(0,0).Style.Font = New Font("宋体", 10, FontStyle.Bold) '设置主标题字体
bg4.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉第一行的网格线
bg4.Rows(0).Style.Borders.Bottom = New prt.Linedef  '恢复第一行底端的网格线
bg4.Rows(0).Height = 8 '设置第一行的高度,拉开和表格主体的距离.
bg4.Rows(1).Height = 10

bg4.Cols(0).Width = 40
bg4.Cols(1).Width = 12
bg4.Cols(2).Width = 12
bg4.Cols(3).Width = 10
bg4.Cols(4).Width = 30
bg4.Cols(5).Width = 12


bg4.Style.TextAlignHorz = prt.AlignHorzEnum.Center '所有文本内容水平居中'
bg4.Style.TextAlignVert = prt.AlignVertEnum.Center '所有文本内容垂直居中'

bg4.Cells(1,0).Text = "款物名称"
bg4.Cells(1,1).Text = "款物数量"
bg4.Cells(1,2).Text = "款物序号"
bg4.Cells(1,3).Text = "使用人"
bg4.Cells(1,4).Text = "登记时间"
bg4.Cells(1,5).Text = "登记状态"

For i As Integer = 0 To drs4.count- 1
    Dim ndr21=drs4(i)
    bg4.Rows(2+i).Height = 10
    bg4.Cells(2+i,0).Text = ndr21("款物名称")
    bg4.Cells(2+i,1).Text = ndr21("款物数量")
    bg4.Cells(2+i,2).Text = ndr21("款物序号")
    bg4.Cells(2+i,3).Text = ndr21("使用人")
    bg4.Cells(2+i,4).Text = ndr21("录入时间")
    bg4.Cells(2+i,5).Text = ndr21("登记状态")
Next
bg4.Style.Spacing.Top=1


'设置页眉
Dim rx As New prt.RenderTable
rx.Cells(0,0).Text = Date.Today
rx.Cells(0,1).Text = " "
rx.Cells(0,2).Text = "第[PageNo]页,共[PageCount]页"
rx.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
rx.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rx.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right
rx.Style.Borders.Bottom = New prt.LineDef '设置底边框
rx.CellStyle.Spacing.Bottom = 0.5 '底端内容缩进0.5毫米
rx.Style.FontSize = 8 '字体大小为8磅
Doc.PageFooter = rx '作为页眉使用
doc.Body.Children.Add(bg)
doc.Body.Children.Add(bg1)
doc.Body.Children.Add(bg2)
doc.Body.Children.Add(bg3)
doc.Body.Children.Add(bg4)

doc.Preview() '预览


[此贴子已经被作者于2017/11/10 18:04:18编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/11/10 18:04:00 [只看该作者]

1、实例请完整上传;

 

2、加入msgbox定位出错位置 http://www.foxtable.com/webhelp/scr/1485.htm

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/11/10 18:07:00 [只看该作者]

没找到,就会报错

 

Dim ndr As DataRow = DataTables("涉案款物").find("案件编号 = '" & currow("卷宗编号") & "'")

 

If ndr Is Nothing Then

    msgbox("没找到对应的行")

    return

End If


 回到顶部
帅哥哟,离线,有人找我吗?
李孝春
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2472 积分:17346 威望:0 精华:0 注册:2013/1/31 0:03:00
回复:(有点甜)没找到,就会报错 Dim ndr ...  发帖心情 Post By:2017/11/11 12:22:00 [只看该作者]

有点甜老师   经过按照上面方法修正后 无法对应写入款物数量了

经过测试
将代码写入
For i As Integer = 0 To drs2.count-1
    Dim ndr11 = drs2(i)
    bg2.Rows(2+i).Height = 20
    bg2.Cells(2+i,0).Text = ndr11("款物名称")
    bg2.Cells(2+i,1).Text = ndr11("款物数量")
    bg2.Cells(2+i,2).Text = ndr11("款物序号")
    bg2.Cells(2+i,3).Image = GetImage(ndr11("二维码"))
    bg.Cells(4,5).Text = ndr11("款物数量")
Next
bg2.Style.Spacing.Top = 1
初步可以实现款物数量的数据获取

不知道有没有更好的办法呢?

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107147 积分:544978 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/11/11 14:37:00 [只看该作者]

能实现就行。专业报表就是一个微调的活

 回到顶部