以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 专业报表 为什么会生成两页呢?数据只有一页 12行 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=160949) |
-- 作者:cnsjroom -- 发布时间:2021/2/27 12:43:00 -- 专业报表 为什么会生成两页呢?数据只有一页 12行 专业报表生成效果如图: 1、为什么会生成两页呢?数据只有一页 12行 2、本页小计和总计 是否可以根据数量 如果只有一页就显示总计 如果大于一页就显示本页 在末尾页显示本页小计和总计 报表代码如下: Dim Names As List(Of String) = Tables("表彰").DataTable.GetValues("登记单位") Dim doc As New PrintDoc Dim prs As Integer = 20 \'每页20行 Dim tb As Table = Tables("表彰") For p As Integer = 1 To math.Ceiling(tb.Rows.Count / prs) - 1 Dim rt As New prt.RenderTable rt.Cells(0,0).Text = "黔南州检察系统表彰统计汇总表" rt.Cells(1,0).Text = "登记单位" rt.Cells(1,1).Text = "总数" rt.Cells(1,2).Text = "个人表彰" rt.Cells(1,7).Text = "集体表彰" rt.Cells(2,0).Text = "登记单位" rt.Cells(2,1).Text = "总数" rt.Cells(2,2).Text = "个人表彰" rt.Cells(2,3).Text = "国家级" rt.Cells(2,4).Text = "省部级" rt.Cells(2,5).Text = "地州级" rt.Cells(2,6).Text = "县市级" rt.Cells(2,7).Text = "集体表彰" rt.Cells(2,8).Text = "国家级" rt.Cells(2,9).Text = "省部级" rt.Cells(2,10).Text = "地州级" rt.Cells(2,11).Text = "县市级" rt.Cells(0,0).SpanCols = 12 \'第1行第1个单元格向右合并12列 rt.Cells(1,0).SpanRows = 2 \'第1行第1个单元格向下合并2行 rt.Cells(1,1).SpanRows = 2 \'第1行第2个单元格向下合并2行 rt.Cells(1,2).SpanCols = 5 \'第1行第3个单元格向右合并3列 rt.Cells(1,7).SpanCols = 5 \'第1行第7个单元格向右合并5列 rt.Cols(0).Width = 40 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'内容水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Rows(0).Style.BackColor = Color.LightGray \'第一行背景颜色设为灰色. rt.Rows(1).Style.BackColor = Color.LightGray \'第一行背景颜色设为灰色. rt.RowGroups(0,4).Header = prt.TableHeaderEnum.All \'将前四行作为表头. rt.Cols(2).Style.BackColor = Color.LightGray \'第一列背景颜色设为灰色. rt.Cols(7).Style.BackColor = Color.LightGray \'第一列背景颜色设为灰色. rt.Cols(1).Style.BackColor = Color.LightGray \'第一列背景颜色设为灰色. rt.Cols(0).Style.BackColor = Color.LightGray \'第一列背景颜色设为灰色. rt.ColGroups(0,1).Header = prt.TableHeaderEnum.All \'将第一列作为表头. rt.Rows(0).Height = 10 For i As Integer = 0 To Names.Count -1 rt.Cells(i+3,0).Text= Names(i) rt.Cells(i+3,1).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","登记单位=\'" & Names(i) & "\'") rt.Cells(i+3,2).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\' And 登记单位=\'" & Names(i) & "\'") rt.Cells(i+3,3).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\' And 获奖等级=\'国家级\' And 登记单位=\'" & Names(i) & "\'") rt.Cells(i+3,4).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\' And 获奖等级=\'省部级\' And 登记单位=\'" & Names(i) & "\'") rt.Cells(i+3,5).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\' And 获奖等级=\'地州级\' And 登记单位=\'" & Names(i) & "\'") rt.Cells(i+3,6).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\' And 获奖等级=\'县市级\' And 登记单位=\'" & Names(i) & "\'") rt.Cells(i+3,7).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\' And 登记单位=\'" & Names(i) & "\'") rt.Cells(i+3,8).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\' And 获奖等级=\'国家级\' And 登记单位=\'" & Names(i) & "\'") rt.Cells(i+3,9).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\' And 获奖等级=\'省部级\' And 登记单位=\'" & Names(i) & "\'") rt.Cells(i+3,10).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\' And 获奖等级=\'地州级\' And 登记单位=\'" & Names(i) & "\'") rt.Cells(i+3,11).Text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\' And 获奖等级=\'县市级\' And 登记单位=\'" & Names(i) & "\'") Next rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线 rt.CellStyle.Spacing.All = 1 \'内容距离网格线1毫米 rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中 rt.Rows.Count = rt.Rows.Count + 1 \'增加本页小计行 rt.Rows(rt.Rows.count -1)(0).text = "本页小计" rt.Rows(rt.Rows.count -1)(1).text = Tables("表彰").DataTable.Compute("Count(获奖者)") rt.Rows(rt.Rows.count -1)(2).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\'") rt.Rows(rt.Rows.count -1)(3).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\'And 获奖等级=\'国家级\'") rt.Rows(rt.Rows.count -1)(4).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\'And 获奖等级=\'省部级\'") rt.Rows(rt.Rows.count -1)(5).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\'And 获奖等级=\'地州级\'") rt.Rows(rt.Rows.count -1)(6).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\'And 获奖等级=\'县市级\'") rt.Rows(rt.Rows.count -1)(7).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\'") rt.Rows(rt.Rows.count -1)(8).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\'And 获奖等级=\'国家级\'") rt.Rows(rt.Rows.count -1)(9).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\'And 获奖等级=\'省部级\'") rt.Rows(rt.Rows.count -1)(10).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\'And 获奖等级=\'地州级\'") rt.Rows(rt.Rows.count -1)(11).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\'And 获奖等级=\'县市级\'") If p = math.Ceiling(tb.Rows.Count / prs) - 1 \'如果是最后一页 rt.Rows.Count = rt.Rows.Count + 1 \'增加总计行 rt.Rows(rt.Rows.count -1)(0).text = "总计" rt.Rows(rt.Rows.count -1)(1).text = Tables("表彰").DataTable.Compute("Count(获奖者)") rt.Rows(rt.Rows.count -1)(2).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\'") rt.Rows(rt.Rows.count -1)(3).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\'And 获奖等级=\'国家级\'") rt.Rows(rt.Rows.count -1)(4).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\'And 获奖等级=\'省部级\'") rt.Rows(rt.Rows.count -1)(5).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\'And 获奖等级=\'地州级\'") rt.Rows(rt.Rows.count -1)(6).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'个人表彰\'And 获奖等级=\'县市级\'") rt.Rows(rt.Rows.count -1)(7).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\'") rt.Rows(rt.Rows.count -1)(8).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\'And 获奖等级=\'国家级\'") rt.Rows(rt.Rows.count -1)(9).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\'And 获奖等级=\'省部级\'") rt.Rows(rt.Rows.count -1)(10).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\'And 获奖等级=\'地州级\'") rt.Rows(rt.Rows.count -1)(11).text = Tables("表彰").DataTable.Compute("Count(获奖者)","表彰类别=\'集体表彰\'And 获奖等级=\'县市级\'") Else rt.BreakAfter = prt.BreakEnum.Page \'否则换页 End If doc.Body.Children.Add(rt) Next doc.Preview() [此贴子已经被作者于2021/2/27 13:58:21编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/2/27 14:09:00 -- 去掉最外层的for循环:For p As Integer = 1 To math.Ceiling(tb.Rows.Count / prs) - 1 |
-- 作者:cnsjroom -- 发布时间:2021/2/27 14:16:00 -- 回复:(有点蓝)去掉最外层的for循环:For p As Inte... 最外层去掉之后会报错 |
-- 作者:有点蓝 -- 发布时间:2021/2/27 14:46:00 -- 一样去掉 或者 For p As Integer = 1 To math.Ceiling(tb.Rows.Count / prs) - 1 改为 For p As Integer = 1 To math.Ceiling(Names.Count / prs) - 1 …… If p = math.Ceiling(tb.Rows.Count / prs) - 1 \'如果是最后一页 改 If p = math.Ceiling(Names / prs) - 1 \'如果是最后一页
|
-- 作者:cnsjroom -- 发布时间:2021/2/27 21:43:00 -- 回复:(有点蓝)一样去掉或者For p As Integer = 1 T... 更改最后一页这个代码后 提示错误 |
-- 作者:有点蓝 -- 发布时间:2021/2/28 20:48:00 -- If p = math.Ceiling(Names.Count / prs) - 1 \'如果是最后一页 |