以下是引用blackzhu在2018/8/1 13:28:00的发言:
Dim nms() As String = {"到诊时间", "客户编号", "客户姓名", "联系电话"}
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Sele ct * From Y_分诊信息 Where " & sql
Dim dt As DataTable = cmd.ExecuteReader
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
For c As Integer = 0 To nms.Length - 1
Sheet(0, c).Value = nms(c)
Next
For r As Integer = 0 To dt.DataRows.Count - 1
For c As Integer = 0 To nms.Length - 1
Sheet(r + 1, c).Value = dt.DataRows(r)(nms(c))
Next
Next
Book.PreBuild = False '非报表模请将PreBuild 属性设置为False
e.WriteBook(Book, "现场咨询.xls", False)
我这样写了,但是浏览器没有下载,这个是是怎么回事?
e.WriteBook(Book, "现场咨询.xls", False)
我测试,没问题,你可以单独测试。