Foxtable(狐表)用户栏目专家坐堂 → 专业报表三层分组,求助


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

主题:专业报表三层分组,求助

帅哥哟,离线,有人找我吗?
yifan3429
  11楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2466 积分:22761 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By:2022/4/24 20:49:00 [只看该作者]

 ---------------------------
错误
---------------------------
编译错误:属性访问必须分配给属性或使用它的值。



错误代码:rt.Rows.Count
---------------------------
确定   
---------------------------


Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("订单_产品主表")
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tbl.DataTable.GetValues("区域名称")
doc.Pagesetting.LandScape = True
For Each Region As String In Regions
    rx = New prt.RenderText
    rx.Style.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "区域: " & Region
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    rt.Style.Font = Tables("订单_产品主表").Font
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.GridLines.All = New prt.LineDef(0.3, Color.LightGray)
    rt.Style.Spacing.Bottom = 5
    rt.CellStyle.Spacing.All = 1
    rt.Style.Font = tbl.Font
    Dim jds As List(Of String) = tbl.DataTable.GetValues("产品ID", "区域名称 = '" & Region & "'")
    For Each jd As String In jds
        Dim ColNames As String() = New String() {"区域楼层", "区域名称", "订单类别", "产品名称", "图片", "工艺描述", "销售单价", "计价单位", "数量", "金额小计", "备注" }
        rt.Rows.Count
        rt.Cells(rt.Rows.Count, 0).SpanCols = ColNames.Length
        rt.Cells(rt.Rows.Count - 1, 0).Style.TextAlignHorz = prt.AlignVertEnum.left
        rt.Cells(rt.Rows.Count - 1, 0).Text = "    " & jd
        rt.Cells(rt.Rows.Count - 1, 0).CellStyle.Font = New Font("宋体", 14, FontStyle.Bold)
        rt.Rows(rt.Rows.Count).Height = 8
        rt.Rows(rt.Rows.Count - 1).Style.BackColor = Color.LightGray
        rt.Rows(rt.Rows.Count - 1).Style.Font = New Font("宋体", 12, FontStyle.Bold)
        For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
            rt.Cells(rt.Rows.Count - 1, c).Text = ColNames(c) '列名作为标题
            rt.Cells(rt.Rows.Count - 1, c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
        Next
        Rows = tbl.DataTable.Select("[区域名称] = '" & Region & "' and 产品ID = '" & jd & "'")
        Dim tb As Table = Tables("订单_产品清单")
        rt.Style.Font = tb.Font
        For r As DataRow In Rows '开始填入该列内容
            rt.Rows(rt.Rows.Count).Height = 6
            For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
                rt.Cells(rt.Rows.Count - 1, c).Text = r(ColNames(c))
            Next
        Next
    Next
    rt.Cols(10).Width = tb.Cols(ColNames("备注")).PrintWidth
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
    rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
    rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
    rt.RowGroups(0, 1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
    doc.Body.Children.Add(rt) '将表格加入到报表
Next
doc.preview()


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


加好友 发短信
等级:超级版主 帖子:107014 积分:544295 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/4/24 20:52:00 [只看该作者]

提示这么明显了,学会调试判断错误的原因。不是别人给了一段代码,就只能被动的等别人来改

 回到顶部
帅哥哟,离线,有人找我吗?
程兴刚
  13楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:超级版主 帖子:7235 积分:40574 威望:0 精华:16 注册:2008/8/31 23:23:00
  发帖心情 Post By:2022/4/24 21:10:00 [只看该作者]

Dim ColNames As String() = New String() {"区域楼层", "区域名称", "订单类别", "产品名称", "图片", "工艺描述", "销售单价", "计价单位", "数量", "金额小计", "备注" }
        rt.Rows.Count

上面这一行rt.Rows.Count是我复制进去备用的,忘了删,自己删除嘛!

 回到顶部
帅哥哟,离线,有人找我吗?
程兴刚
  14楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:超级版主 帖子:7235 积分:40574 威望:0 精华:16 注册:2008/8/31 23:23:00
  发帖心情 Post By:2022/4/24 21:13:00 [只看该作者]

前面重新编辑了,自己要去消化,而不仅是拿来用思维!

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


加好友 发短信
等级:九尾狐 帖子:2466 积分:22761 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By:2022/4/24 22:31:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:企业微信截图_20220424223230.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:企业微信截图_20220424223201.png
图片点击可在新窗口打开查看
以下是引用有点蓝在2022/4/24 20:52:00的发言:
提示这么明显了,学会调试判断错误的原因。不是别人给了一段代码,就只能被动的等别人来改

调试过的,又会有其他的错误出现呢

[此贴子已经被作者于2022/4/24 22:32:55编辑过]

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


加好友 发短信
等级:超级版主 帖子:107014 积分:544295 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/4/24 22:51:00 [只看该作者]

提示一样的明显,都不是复杂的错误,基本是手误输错的....

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


加好友 发短信
等级:九尾狐 帖子:2466 积分:22761 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By:2022/4/24 23:24:00 [只看该作者]

以下是引用有点蓝在2022/4/24 22:51:00的发言:
提示一样的明显,都不是复杂的错误,基本是手误输错的....
结果和这个是一样的,但是这个是New prt.RenderText 
没见过正确的New prt.RenderTable 实例,帮助也没有同样的 不晓得从哪下手,或是举一反三。还需要老师指导,
就是两张表 三个层级  主表  子表 主表和子表丛属关系通过ID关联(未设置关联表)  主表记录里了 区域 和房子  第一次分组将同一区域的房子分组,子表记录了房子内有的家具
目前的  第一次分组将同一区域的房子分组  已经完成   现在 希望导出 子表记录了房子内有的家具

[此贴子已经被作者于2022/4/24 23:32:32编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
程兴刚
  18楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:超级版主 帖子:7235 积分:40574 威望:0 精华:16 注册:2008/8/31 23:23:00
  发帖心情 Post By:2022/4/24 23:43:00 [只看该作者]

1、确实如蓝版所说,遍历语句手误:For r应为For Each r
2、刚使用新的代码编辑器,还不是很习惯,将文字水平对齐搞成了上下对齐,手写了left,犯了这种低级错误;
      
      您自己要自己要学会识别错误位置和改错才行,改这个并不难!


Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("订单_产品主表")
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tbl.DataTable.GetValues("区域名称")
doc.Pagesetting.LandScape = True
For Each Region As String In Regions
    rx = New prt.RenderText
    rx.Style.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "区域: " & Region
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    rt.Style.Font = Tables("订单_产品主表").Font
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.GridLines.All = New prt.LineDef(0.3, Color.LightGray)
    rt.Style.Spacing.Bottom = 5
    rt.CellStyle.Spacing.All = 1
    rt.Style.Font = tbl.Font
    Dim jds As List(Of String) = tbl.DataTable.GetValues("酒店名称", "区域名称 = '" & Region & "'")
    For Each jd As String In jds
        Dim ColNames As String() = New String() {"区域楼层", "区域名称", "订单类别", "产品名称", "图片", "工艺描述", "销售单价", "计价单位", "数量", "金额小计", "备注" }
        rt.Cells(rt.Rows.Count, 0).SpanCols = ColNames.Length
        rt.Cells(rt.Rows.Count - 1, 0).Style.Style.TextAlignHorz = prt.AlignHorzEnum.left
        rt.Cells(rt.Rows.Count - 1, 0).Text = "    " & jd
        rt.Cells(rt.Rows.Count - 1, 0).CellStyle.Font = New Font("宋体", 14, FontStyle.Bold)
        rt.Rows(rt.Rows.Count).Height = 8
        rt.Rows(rt.Rows.Count - 1).Style.BackColor = Color.LightGray
        rt.Rows(rt.Rows.Count - 1).Style.Font = New Font("宋体", 12, FontStyle.Bold)
        For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
            rt.Cells(rt.Rows.Count - 1, c).Text = ColNames(c) '列名作为标题
            rt.Cells(rt.Rows.Count - 1, c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
        Next
        Rows = tbl.DataTable.Select("[区域名称] = '" & Region & "' and 酒店名称 = '" & jd & "'")
        Dim tb As Table = Tables("订单_产品主表")
        rt.Style.Font = tb.Font
        For Each r As DataRow In Rows '开始填入该列内容
            rt.Rows(rt.Rows.Count).Height = 6
            For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
                rt.Cells(rt.Rows.Count - 1, c).Text = r(ColNames(c))
            Next
        Next
    Next
    rt.Cols(10).Width = tb.Cols(ColNames("备注")).PrintWidth
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
    rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
    rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
    rt.RowGroups(0, 1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
    doc.Body.Children.Add(rt) '将表格加入到报表
Next
doc.preview()


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


加好友 发短信
等级:九尾狐 帖子:2466 积分:22761 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By:2022/4/25 [只看该作者]

还是不对
下图是一级分组报表的结果

图片点击可在新窗口打开查看此主题相关图片如下:企业微信截图_20220425000123.png
图片点击可在新窗口打开查看
产品主表和产品子表通过产品订购ID 代码建立关联
下图是系统表截图
 
图片点击可在新窗口打开查看此主题相关图片如下:企业微信截图_20220424235839.png
图片点击可在新窗口打开查看
[此贴子已经被作者于2022/4/25 0:37:45编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
程兴刚
  20楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:超级版主 帖子:7235 积分:40574 威望:0 精华:16 注册:2008/8/31 23:23:00
  发帖心情 Post By:2022/4/25 0:41:00 [只看该作者]

我没有安装商业版,自己测试一下!


Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("订单_产品主表")
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tbl.DataTable.GetValues("区域名称")
doc.Pagesetting.LandScape = True
For Each Region As String In Regions
    rx = New prt.RenderText
    rx.Style.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "区域: " & Region
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    rt.Style.Font = Tables("订单_产品主表").Font
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.GridLines.All = New prt.LineDef(0.3, Color.LightGray)
    rt.Style.Spacing.Bottom = 5
    rt.CellStyle.Spacing.All = 1
    rt.Style.Font = tbl.Font
    Dim jds As List(Of String) = tbl.DataTable.GetValues("酒店名称", "区域名称 = '" & Region & "'")
    For Each jd As String In jds
        Dim ColNames As String() = New String() {"区域楼层", "区域名称", "订单类别", "产品名称", "图片", "工艺描述", "销售单价", "计价单位", "数量", "金额小计", "备注" }
        rt.Cells(rt.Rows.Count, 0).SpanCols = ColNames.Length
        rt.Cells(rt.Rows.Count - 1, 0).Style.Style.TextAlignHorz = prt.AlignHorzEnum.left
        rt.Cells(rt.Rows.Count - 1, 0).Text = "    " & jd
        rt.Cells(rt.Rows.Count - 1, 0).CellStyle.Font = New Font("宋体", 14, FontStyle.Bold)
        rt.Rows(rt.Rows.Count).Height = 8
        rt.Rows(rt.Rows.Count - 1).Style.BackColor = Color.LightGray
        rt.Rows(rt.Rows.Count - 1).Style.Font = New Font("宋体", 12, FontStyle.Bold)
        For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
            rt.Cells(rt.Rows.Count - 1, c).Text = ColNames(c) '列名作为标题
            rt.Cells(rt.Rows.Count - 1, c).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
        Next
        Rows = tbl.DataTable.Select("[区域名称] = '" & Region & "' and 酒店名称 = '" & jd & "'")
        Dim tb As Table = Tables("订单_产品主表")
        rt.Style.Font = tb.Font
        For Each r As DataRow In Rows '开始填入该列内容
            rt.Rows(rt.Rows.Count).Height = 6
            For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
                rt.Cells(rt.Rows.Count - 1, c).Text = r(ColNames(c))
            Next
            Dim drs As list(Of DataRow) = DataTables("订单_产品清单").Select("[区域名称] = '" & Region & "' and 酒店名称 = '" & jd & "'")
            For Each r1 As DataRow In drs '开始填入该列内容
                rt.Rows(rt.Rows.Count).Height = 6
                For c1 As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
                    rt.Cells(rt.Rows.Count - 1, c).Text = r1(ColNames(c))
                Next
            Next
        Next
    Next
    rt.Cols(10).Width = tb.Cols(ColNames("备注")).PrintWidth
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
    rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
    rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
    rt.RowGroups(0, 1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
    doc.Body.Children.Add(rt) '将表格加入到报表
Next
doc.preview()


 回到顶部
总数 31 上一页 1 2 3 4 下一页