以文本方式查看主题 - Foxtable(狐表) (http://www.foxtable.com/bbs/index.asp) -- 专家坐堂 (http://www.foxtable.com/bbs/list.asp?boardid=2) ---- 报表 (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=94345) |
-- 作者:刘林 -- 发布时间:2016/12/21 15:37:00 -- 报表 e.Form.Controls("RadioButton1").Select() Dim doc As New PrintDoc Dim rt As Prt.RenderTable Dim rx As prt.RenderText Dim tbl As Table = Tables("统计_table1") tbl.sort = "单位名称,考试名称,年级代码,班级,折总 desc" Dim Rows As List(Of DataRow) Dim Regions As List(Of String()) = tbl.DataTable.GetValues("考试名称|单位名称|年级代码|班级") \'\'\'\'改后句子 Dim s As Integer = regions.Count Dim rm As prt.RenderEmpty Doc.PageSetting.LeftMargin = 5 \'设置左边距 Doc.PageSetting.RightMargin = 5 \'设置右边距 Doc.PageSetting.TopMargin = 5 \'设置上边距 Doc.PageSetting.BottomMargin = 5 \'设置下边距 For Each region As String() In Regions rm = new prt.RenderEmpty \'定义一个新的空对象 rm.BreakBefore = prt.BreakEnum.Page \'打印前换页 doc.Body.Children.Add(rm) rx = New prt.RenderText rx.Style.Font = New Font("黑体", 16, FontStyle.Bold) \' rx.Style.FontBold = True rx.Style.Spacing.Bottom = 2 rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center rx.Text = Region(1) & Region(0) & Region(2) & "级" & Region(3) & "班成绩表" doc.Body.Children.Add(rx) rt = New prt.RenderTable rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中 rt.Style.GridLines.All = New prt.LineDef(0.3,Color.black) rt.Width = "auto" rt.Style.Font = New Font("宋体", 8) Rows = tbl.DataTable.Select("[单位名称] = \'" & region(1) & "\'and [班级] =\'" & region(3) & "\'and [年级代码] =\'" & region(2) & "\'and [考试名称] =\'" & region(0) &"\'", "班序") For c As Integer = 6 To tbl.Cols.Count -1 \' If tbl.Cols(c).Visible Then If c = 6 rt.Cols(c-6).Width = 12 Else rt.Cols(c-6).Width = 9 End If If tbl.Cols(c).Name.Contains("_") Then Dim Values() As String Values = tbl.Cols(c).name.split("_") Dim s As String = values(0) & values(1) rt.Cells(0,c-6).Text = s Else rt.Cells(0,c-6).Text = tbl.Cols(c).Name End If Dim r As Integer For r = 0 To Rows.Count -1 rt.Rows(0).Height = 5 rt.Rows(r+1).height = 4 rt.Cells(r+1,c-6).Text = rows(r)(tbl.Cols(c).Name) Next rt.Cells(r+1,0).Text = "班级平均" rt.Cells(r+2,0).Text = "学校平均" If "单位名称考试名称年级班级姓名班序校序".Contains(tbl.Cols(c).Name) = False Then rt.Rows(r+1).height = 6 rt.Rows(r+2).height = 6 rt.Cells(r+1,c-6).Text = format(tbl.DataTable.sqlCompute("Avg(" & tbl.Cols(c).Name & ")","[单位名称] = \'" & region(1) & "\'and [班级] =\'" & region(3) & "\'and [年级代码] =\'" & region(2) & "\'and [考试名称] =\'" & region(0) & "\'"),"#.00") rt.Cells(r+2,c-6).Text = format(tbl.DataTable.sqlCompute("Avg(" & tbl.Cols(c).Name & ")","[单位名称] = \'" & region(1) & "\'and [年级代码] =\'" & region(2) & "\'and [考试名称] =\'" & region(0) & "\'"),"#.00") End If End If Next rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All doc.Body.Children.Add(rt) Next doc.preview() 老师,我想将班级平均改为全校的各班平均都列出来,学校平均放在最后,请问怎么改?
|
-- 作者:有点色 -- 发布时间:2016/12/21 16:11:00 -- rt.Cells(r+3,c-6).Text = format(tbl.DataTable.sqlCompute("Avg(" & tbl.Cols(c).Name & ")","[单位名称] = \'" & region(1) & "\' and [考试名称] =\'" & region(0) & "\'"),"#.00") |
-- 作者:刘林 -- 发布时间:2016/12/21 20:00:00 -- 老师,你这个是不是把同单位考试名称,不分年级把成绩平均列在r+3行,我是想把同单位,同年级,同考试名称不同班级的平均排在明细表的后面,方便比较同次考试各班的平均,如一个年级有3个班,把3个班的各科成绩排在表尾,方便看总的结果,这样就打印每个班的平均成绩时都附有其他班的平均情况 |
-- 作者:有点色 -- 发布时间:2016/12/21 20:16:00 -- 上传实例。 |
-- 作者:有点色 -- 发布时间:2016/12/21 20:22:00 -- Dim ii As integer = 1 For each bj as string in tbl.DataTable.GetValues("班级", "[单位名称] = \'" & region(1) & "\' and [年级代码] =\'" & region(2) & "\'and [考试名称] =\'" & region(0) &"\'", "班序") rt.Cells(r+2+i,c-6).Text = format(tbl.DataTable.sqlCompute("Avg(" & tbl.Cols(c).Name & ")","[单位名称] = \'" & region(1) & "\'and [年级代码] =\'" & region(2) & "\'and [考试名称] =\'" & region(0) & "\' and [班级] = \'" & bj & "\'"),"#.00") ii += 1 next |
-- 作者:刘林 -- 发布时间:2016/12/22 8:39:00 -- Dim ii As Integer = 1 For Each bj As String In tbl.DataTable.sqlGetValues("班级", "[单位名称] = \'" & region(1) & "\' and [年级代码] =\'" & region(2) & "\'and [考试名称] =\'" & region(0) &"\'", "班序") rt.Cells(r+ii,c-6).Text = format(tbl.DataTable.sqlCompute("Avg(" & tbl.Cols(c).Name & ")","[单位名称] = \'" & region(1) & "\'and [年级代码] =\'" & region(2) & "\'and [考试名称] =\'" & region(0) & "\' and [班级] = \'" & bj & "\'"),"#.00") rt.Cells(r+1+ii,c-6).Text = format(tbl.DataTable.sqlCompute("Avg(" & tbl.Cols(c).Name & ")","[单位名称] = \'" & region(1) & "\'and [年级代码] =\'" & region(2) & "\'and [考试名称] =\'" & region(0) & "\'"),"#.00") rt.Cells(r+ii,0).Text = bj & "班平均" rt.cells(r+1+ii,0).text = "年级平均" rt.Rows(r+ii).height =5 rt.Rows(r+1+ii).height =6 ii += 1 Next 老师改起了,学习到有很有用的东西,谢谢
|
-- 作者:刘林 -- 发布时间:2016/12/22 8:43:00 -- 请问如何判断表中某行至少有一列内容为空,用于做某记录的内容没填完,谢谢 |
-- 作者:有点蓝 -- 发布时间:2016/12/22 8:45:00 -- 循环所有列,逐个判断 |
-- 作者:有点色 -- 发布时间:2016/12/22 9:04:00 -- 以下是引用刘林在2016/12/22 8:43:00的发言:
请问如何判断表中某行至少有一列内容为空,用于做某记录的内容没填完,谢谢
For Each dc As DataCol In DataTables("表A").DataCols |