老师,您好。
你的方法数据是获得了,但不知道分页要怎么处理?
比如用查询表生成的数据:
Dim q As new Q u eryBuilder
Q.C o n necti
q.T a bleName = "统计表1"
q.S e l ectString = "S el ect 类型,打卡时间 From {***}"
q.Build
'MainTable = Tables("统计表1")
DataTables("统计表1").DataCols("打卡时间").S e tDateTimeFormat(DateTimeFormatEnum.DateLongTime)
老办法的分类代码是这样的,但我不知道怎么去套:
'获取要显示的页
Dim page As Integer = 0 '默认page为0,显示第一页
Dim pageRows As Integer = 10 '每页15行
If e.GetValues.ContainsKey("page") Then '如果地址中有page参数
Integer.TryParse(e.GetValues("page"), page) '提取page参数
End If
Dim StartRow As Integer = page * pageRows + 1 '此页第一行
Dim EndRow As Integer = (page + 1) * pageRows '此页最后一行
'获取该页数据
Dim c m d As New S Q L Command
cmd.C o n nection Na me = "wx" '记得设置数据源名称
cmd.C o mmandText = "S e lect Count(*) From {***} where " & flt
Dim C o unt As Integer = c md.E xecuteScalar() '获取总的行数
cmd.C o mmandText = "S e lect * From (S e l ect Row_Number() Over(Order by 打卡时间 Desc) As [NO.],[_Identify],打卡时间,操作日期,操作时间 From *** where " & flt &") As a"
cmd.C o mmandText = cmd.C o mmandText & " Where [NO.]>= " & StartRow & " And [NO.] <= " & EndRow
Dim dt As DataTable = cmd.E x ecuteReader
'根据此页数据生成网页
With wb.AddTable("","Table1")
.PageNumber = page '设置页码
.Primarykey = "_Identify" '设置主键
.BooleanSymbol= "√×" '设置逻辑列(回复)显示形式
.ActiveSheet = "menu" '设置菜单
.CreateFromDataTable(dt)
End With