Foxtable(狐表)用户栏目专家坐堂 → 下载


  共有1736人关注过本帖树形打印复制链接

主题:下载

帅哥哟,离线,有人找我吗?
刘林
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
下载  发帖心情 Post By:2017/8/23 16:51:00 [显示全部帖子]

Dim e As RequestEventArgs = args(0)
Dim  cmd As new SQLCommand
cmd.Co
Dim dr As DataRow = DataTables("用户").sqlfind("身份证号 = '" & e.Cookies("username") & "'")
Dim  nms() As String
Dim zds() As String
If e.postvalues("bj")="初中"
    If e.PostValues.ContainsKey("cjms") Then
        If e.postvalues("cjms") = "普通模式" Then
            nms = new String() {"班级全称","姓名","语文","数学","英语","政治","历史","生物","地理","物理","化学","总分","总分班序","总分校序"}
            zds = new String() {"班级全称","姓名","语文_语总","数学_数总","英语_英总","政治_政总","历史_历总","生物_","地理_","物理_物总","化学_化总","总分","总分班序","总分校序"}
            cmd.CommandText= "selt 班级全称,考试名称,姓名,语文_语总,数学_数总,英语_英总,政治_政总,历史_历总,生物_,地理_,物理_物总,化学_化总,总分,总分班序,总分校序,免统审核 From {成绩}  where 单位名称 = '" & dr("group") & "' And 考试名称 =  '" & e.PostValues("ksmc") & "' order by 班级全称,总分 desc"  '班级全称 = '" & e.postvalues("bj") & "' and
        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= "set 班级全称,考试名称,姓名,语文_A,语文_B,数学_A,数学_B,英语_A,英语_B,政治_A,政治_B,历史_A,历史_B,生物_,地理_,物理_A,物理_B,化学_A,化学_B,折总,班序,校序,免统审核 From {成绩} where 单位名称 = '" & dr("group") & "' And 考试名称 =  '" & e.PostValues("ksmc") & "' order by 班级全称,折总 desc"
        End If
    End If
End If
If e.postvalues("bj")="小学"
    nms = new String() {"班级全称","姓名","语文","数学","英语","思品","科学","双科总分","总分班序","总分校序"}
    zds = new String() {"班级全称","姓名","语文_语总","数学_数总","英语","思品","科学","总分","总分班序","总分校序"}
    cmd.CommandText= "se 班级全称,考试名称,姓名,语文_语总,数学_数总,英语,思品,科学,总分,总分班序,总分校序,免统审核 From {成绩}  where 单位名称 = '" & 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("ksmc") & "成绩表"
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
For c As Integer = 2 To nms.Length - 1
 Sheet(h+2, c).Value = nms(c)
Next
Dim i As Integer=1
Dim bjqcs As List(Of String) = dt.GetValues("班级全称")
For Each bjqc As String In bjqcs
 sheet(h+2+i,0).value=bjqc & "平均分"
   For c1 As Integer = 2 To dt.DataCols.count -5
      sheet(h+2+i,c1).value = Format(dt.compute("avg(" & zds(c1) & ")","[班级全称] = '" & bjqc & "' and 免统审核 =false"),"0.00")
   Next
    i=i+1
Next
book.PreBuild = False  '非报表模请将PreBuild  属性设置为False
e.WriteBook(book,"成绩.xls",False)

 

 

老师,请问上面代码用于生成EXCL表,但同样的代码同样的选项,有时能下载,有时点确定后不动定,是什么原因?


 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2017/8/23 21:36:00 [显示全部帖子]

关键是什么也没变,有时能下载,有时不能,没找出问题


 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2017/8/23 22:46:00 [显示全部帖子]

Dim e As RequestEventArgs = args(0)
Dim  cmd As new SQLCommand
Dim wb As new WeUI
cmd.ConnectionName =
Dim dr As DataRow = DataTables("用户").sqlfind("身份证号 = '" & e.Cookies("username") & "'")
Dim  nms() As String
Dim zds() As String
If e.postvalues("bj")="初中"
    'If e.PostValues.ContainsKey("cjms") Then
    If e.postvalues("cjms") = "普通模式" Then
        nms = new String() {"班级全称","姓名","语文","数学","英语","政治","历史","生物","地理","物理","化学","总分","总分班序","总分校序"}
        zds = new String() {"班级全称","姓名","语文_语总","数学_数总","英语_英总","政治_政总","历史_历总","生物_","地理_","物理_物总","化学_化总","总分","总分班序","总分校序"}
        cmd.CommandText= "selt 班级全称,考试名称,姓名,语文_语总,数学_数总,英语_英总,政治_政总,历史_历总,生物_,地理_,物理_物总,化学_化总,总分,总分班序,总分校序,免统审核 From {成绩}  where 单位名称 = '" & dr("group") & "' And 考试名称 =  '" & e.PostValues("ksmc") & "' order by 班级全称,总分 desc"  '班级全称 = '" & e.postvalues("bj") & "' and
    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= "selt 班级全称,考试名称,姓名,语文_A,语文_B,数学_A,数学_B,英语_A,英语_B,政治_A,政治_B,历史_A,历史_B,生物_,地理_,物理_A,物理_B,化学_A,化学_B,折总,班序,校序,免统审核 From {成绩} where 单位名称 = '" & dr("group") & "' And 考试名称 =  '" & e.PostValues("ksmc") & "' order by 班级全称,折总 desc"
    End If
    ' End If
End If
If e.postvalues("bj")="小学"
    nms = new String() {"班级全称","姓名","语文","数学","英语","思品","科学","双科总分","总分班序","总分校序"}
    zds = new String() {"班级全称","姓名","语文_语总","数学_数总","英语","思品","科学","总分","总分班序","总分校序"}
    cmd.CommandText= "sect 班级全称,考试名称,姓名,语文_语总,数学_数总,英语,思品,科学,总分,总分班序,总分校序,免统审核 From {成绩}  where 单位名称 = '" & 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("ksmc") & "成绩表"
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
For c As Integer = 2 To nms.Length - 1
 Sheet(h+2, c).Value = nms(c)
Next
Dim i As Integer=1
Dim bjqcs As List(Of String) = dt.GetValues("班级全称")
For Each bjqc As String In bjqcs
 sheet(h+2+i,0).value=bjqc & "平均分"
  For c1 As Integer = 2 To dt.DataCols.count -5
    sheet(h+2+i,c1).value = Format(dt.compute("avg(" & zds(c1) & ")","[班级全称] = '" & bjqc & "' and 免统审核 =false"),"0.00")
  Next
  i=i+1
Next
book.PreBuild = False  '非报表模请将PreBuild  属性设置为False
messagebox.show("到这里了")
e.WriteBook(book,"成绩.xls",False)
messagebox.show("到这里了")

老师,在上面加了这两句测试,点两次提示的确定,不论什么情况都打得开EXCL,但只要不要这两句就有时打得开,有时打不开,是什么情况?怎么办?


 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2017/8/24 8:20:00 [显示全部帖子]

跟6楼的结果差不多
book.PreBuild = False  '非报表模请将PreBuild  属性设置为False
messagebox.show(Date.now)
e.WriteBook(book,"成绩.xls",False)
messagebox.show(Date.now)
messagebox.show("----------------------------")

只要用这个方式测试每次都能下载打开,但把show语句删了就不行,整晕完了,前面反复检查应该没问题,请老师救救我

 回到顶部