Dim e As RequestEventArgs = args(0)
Dim flt As String
Dim cmd As new SQLCommand
cmd.Co = "180.153.108.50"
Dim dr As DataRow = DataTables("用户").sqlfind("身份证号 = '" & e.Cookies("username") & "'")
Dim nms() As String
Dim zds() As String
If e.postvalues("bj").Substring(0,2)="初中"
If e.PostValues.ContainsKey("cjms") Then
If e.postvalues("cjms") = "普通模式" Then
nms = new String() {"姓名","语文","数学","英语","政治","历史","生物","地理","物理","化学","总分","总分班序","总分校序"}
zds = new String() {"姓名","语文_语总","数学_数总","英语_英总","政治_政总","历史_历总","生物_","地理_","物理_物总","化学_化总","总分","总分班序","总分校序"}
cmd.CommandText= "set 班级全称,考试名称,姓名,语文_语总,数学_数总,英语_英总,政治_政总,历史_历总,生物_,地理_,物理_物总,化学_化总,总分,总分班序,总分校序 From {成绩} where 班级全称 = '" & e.postvalues("bj") & "' and 单位名称 = '" & dr("group") & "' And 考试名称 = '" & e.PostValues("ksmc") & "' order by 总分 desc"
End If
If e.postvalues("cjms") = "加试模式" Then
nms = new String() {"姓名","语文A","语文B","数学A","数学B","英语A","英语B","政治A","政治B","历史A","历史B","生物","地理","物理A","物理B","化学A","化学B","折总","班序","校序"}
zds = new String() {"姓名","语文_A","语文_B","数学_A","数学_B","英语_A","英语_B","政治_A","政治_B","历史_A","历史_B","生物_","地理_","物理_A","物理_B","化学_A","化学_B","折总","班序","校序"}
cmd.CommandText= "selc 班级全称,考试名称,姓名,语文_A,语文_B,数学_A,数学_B,英语_A,英语_B,政治_A,政治_B,历史_A,历史_B,生物_,地理_,物理_A,物理_B,化学_A,化学_B,折总,班序,校序 From {成绩} where 班级全称 = '" & e.postvalues("bj") & "' and 单位名称 = '" & dr("group") & "' And 考试名称 = '" & e.PostValues("ksmc") & "' order by 折总 desc"
End If
End If
End If
If e.postvalues("bj").Substring(0,2)="小学"
nms = new String() {"姓名","语文","数学","英语","思品","科学","双科总分","总分班序","总分校序"}
zds = new String() {"姓名","语文_语总","数学_数总","英语","思品","科学","总分","总分班序","总分校序"}
cmd.CommandText= "set 班级全称,考试名称,姓名,语文_语总,数学_数总,英语,思品,科学,总分,总分班序,总分校序 From {成绩} where 班级全称 = '" & e.postvalues("bj") & "' and 单位名称 = '" & dr("group") & "' And 考试名称 = '" & e.PostValues("ksmc") & "' order by 总分 desc"
End If
Dim dt As DataTable = cmd.ExecuteReader
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
sheet(0,0).value = dr("group") & e.postvalues("bj") & e.PostValues("ksmc") & "成绩表"
Sheet.MergeCell(0,0,0,20)
For c As Integer = 0 To nms.Length - 1
Sheet(1, c).Value = nms(c)
Next
For r As Integer = 0 To dt.DataRows.Count - 1
For c As Integer = 0 To zds.Length - 1
Sheet(r+2, c).Value = dt.Datarows(r)(zds(c))
Next
Next
Dim h As Integer = dt.DataRows.count
sheet(h+2,0).value="班级平均分"
SHEET(H+3,0).VALUE="最高分值"
sheet(h+4,0).value="最低分值"
For c1 As Integer = 1 To dt.DataCols.count -5
sheet(h+2,c1).value = dt.compute("avg(" & zds(c1) & ")")
sheet(h+3,c1).value = dt.compute("max(" & zds(c1) & ")")
sheet(h+4,c1).value = dt.compute("min(" & zds(c1) & ")")
Next
book.PreBuild = False '非报表模请将PreBuild 属性设置为False
e.WriteBook(book,"成绩.xls",False)
Return
在HttpRequest事件可下载,但写成内部函数提示:错误:retren呢