以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 专业报表三层分组,求助 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=176713) |
||||
-- 作者:yifan3429 -- 发布时间:2022/4/24 10:44:00 -- 专业报表三层分组,求助 \'Dim e = args(0) Dim doc As New PrintDoc Dim rt As Prt.RenderTable Dim rx As prt.RenderText \'定义一个文本对象 Dim rm As New prt.RenderImage() \'定义一个图片对象 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 = 10 rx.Style.FontBold = True rx.Style.Spacing.Bottom = 1 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 = 2 rt.CellStyle.Spacing.All = 1 rt.Style.Font = tbl.Font Rows = tbl.DataTable.Select("[区域名称] = \'" & Region & "\'") Dim tb As Table = Tables("订单_产品主表") Dim ColNames As String() = New String(){"区域楼层","产品名称","图片","工艺描述","销售单价","计价单位","数量","金额小计","备注"} rt.Style.Font = tb.Font For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内容 rt.Cells(0,c).Text = ColNames(c) \'列名作为标题 rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中 If ColNames(c) <> "备注" Then \' rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth End If For r As Integer = 0 To Rows .Count -1 \'开始填入该列内容 rt.Cells(r + 1, c).Text = Rows (r)(ColNames(c)) Next 下面的清单和主表通过 产品ID 识别 不是关联表 Dim ColNames1 As String() = New String(){"区域楼层","产品名称","图片","工艺描述","销售单价","计价单位","数量","金额小计","备注"} rt.Style.Font = tb.Font For c1 As Integer = 0 To ColNames1.Length - 1 \'逐列设置和填入内容 rt.Cells(0,c1).Text = ColNames1(c1) \'列名作为标题 rt.Cells(0,c1).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中 If ColNames(c1) <> "备注" Then \' rt.Cols(c1).Width = tb.Cols(ColNames1(c1)).PrintWidth End If For r As Integer = 0 To Rows .Count -1 \'开始填入该列内容 rt.Cells(r + 1, c1).Text = Rows (r)(ColNames1(c1)) Next Next Next rt.Style.GridLines.All = New prt.Linedef \'设置网格线 rt.Cols(0).Width = 20 \'设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列) rt.Cols(1).Width = 35 rt.Cols(2).Width = 30 rt.Cols(3).Width = 50 rt.Cols(4).Width = 20 rt.Cols(5).Width = 20 rt.Cols(6).Width = 10 rt.Cols(7).Width = 30 rt.CellStyle.Spacing.All = 0.4 \'内容距离网格线0.5毫米 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'第一行内容垂直居中 \'rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中 \'rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center \'第一行内容垂直居中 rt.Rows(0).Style.BackColor = Color.FloralWhite \'第一行背景颜色设为灰色. rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'将第一行作为表头.. doc.Body.Children.Add(rt) \'将表格加入到报表 Next doc.preview() [此贴子已经被作者于2022/4/24 10:56:27编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2022/4/24 10:50:00 -- 请上传实例测试,并截图说明需要的实际效果 |
||||
-- 作者:程兴刚 -- 发布时间:2022/4/24 11:08:00 -- 给您帮助过的内容您看过试过吗?帖子回复了吗? 您非得要固执到底,没法帮您! 您也不想想,您这样先列后行地生成,每设置一个列标题,就要将rows所有行往专业报表中写一遍,根据您目前的字段数,这些行各字段值被重复写了9遍,再生成所有区域的拍表,其效率何等低下!既然为您改为先行后列的嵌套遍历,就有我的道理,您自己都不关注,怎能靠别人上心!
|
||||
-- 作者:yifan3429 -- 发布时间:2022/4/24 14:13:00 -- 以下是引用程兴刚在2022/4/24 11:08:00的发言:
给您帮助过的内容您看过试过吗?帖子回复了吗? 您非得要固执到底,没法帮您! 您也不想想,您这样先列后行地生成,每设置一个列标题,就要将rows所有行往专业报表中写一遍,根据您目前的字段数,这些行各字段值被重复写了9遍,再生成所有区域的拍表,其效率何等低下!既然为您改为先行后列的嵌套遍历,就有我的道理,您自己都不关注,怎能靠别人上心! 二层分组已经可以了,目前还有增加一级子项
|
||||
-- 作者:yifan3429 -- 发布时间:2022/4/24 14:17:00 -- 以下是引用有点蓝在2022/4/24 10:50:00的发言: 请上传实例测试,并截图说明需要的实际效果 好的
|
||||
-- 作者:程兴刚 -- 发布时间:2022/4/24 16:05:00 -- 请仔细分析我3楼给的提示,您的代码效率太低,作为开发者,应当优化改进,不仅仅是可以了! |
||||
-- 作者:yifan3429 -- 发布时间:2022/4/24 16:50:00 -- 谢谢 老师的教诲,一直在努力理解和测试。要学的太多了。 |
||||
-- 作者:yifan3429 -- 发布时间:2022/4/24 17:15:00 -- 现在的结果 期望达成结果,客户订购的产品类别,分别有哪些产品 此主题相关图片如下:企业微信截图_20220424170859.png 实例
[此贴子已经被作者于2022/4/24 17:16:54编辑过]
|
||||
-- 作者:程兴刚 -- 发布时间:2022/4/24 19:45: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).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 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()
[此贴子已经被作者于2022/4/24 21:11:21编辑过]
|
||||
-- 作者:程兴刚 -- 发布时间:2022/4/24 19:49: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.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 酒店名称 = \'" & 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() [此贴子已经被作者于2022/4/24 21:11:49编辑过]
|